edoardocomar commented on code in PR #15530:
URL: https://github.com/apache/kafka/pull/15530#discussion_r1526237310


##########
core/src/test/scala/unit/kafka/server/KafkaServerTest.scala:
##########
@@ -42,6 +42,32 @@ class KafkaServerTest extends QuorumTestHarness {
     TestUtils.shutdownServers(Seq(server1, server2))
   }
 
+  @Test
+  def testListenerPortAlreadyInUse(): Unit = {
+    val serverSocket = new ServerSocket(0, 0, InetAddress.getLoopbackAddress)
+    val thread = new Thread {
+      override def run : Unit = {
+        while (true) {
+          serverSocket.accept()
+        }
+      }
+    }
+    thread.start()

Review Comment:
   good catch, thanks @showuon 
   Actually there's no need for the socket to accept connections, it's enough 
for it to be bound.
   It should be bound at creation, but in any case I enclosed a wait.
   I also clean up in a more idiomatic way now.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to