Skip to content

Commit

Permalink
Make trivialSocketHolder a singleton.
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanLennox committed Oct 21, 2024
1 parent 1f3cd1b commit 1dde751
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/kotlin/org/ice4j/socket/SocketPool.kt
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ class SocketPool(
}

/** Trivial socket holder that gives out a single unique socket. */
private inner class TrivialSocketHolder : SocketHolder {
private val trivialSocketHolder = object : SocketHolder {
override val socket = sockets.first()
override fun close() {}
}

/** Gets a send socket holder. Should be used with Kotlin [use] or Java try-with-resources. May block. */
fun getSendSocket(): SocketHolder {
if (numSockets == 1) {
return TrivialSocketHolder()
return trivialSocketHolder
}
return MySocketHolder()
}
Expand Down

0 comments on commit 1dde751

Please sign in to comment.