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


##########
core/src/test/scala/unit/kafka/server/KafkaServerTest.scala:
##########
@@ -42,6 +43,24 @@ class KafkaServerTest extends QuorumTestHarness {
     TestUtils.shutdownServers(Seq(server1, server2))
   }
 
+  @Test
+  def testListenerPortAlreadyInUse(): Unit = {
+    val serverSocket = new ServerSocket(0, 0, InetAddress.getLoopbackAddress)
+
+    var kafkaServer : Option[KafkaServer] = None
+    try {
+      TestUtils.waitUntilTrue(() => serverSocket.isBound, "Server socket 
failed to bind.")
+      // start a server with listener on the port already bound
+      assertThrows(classOf[RuntimeException],
+        () => kafkaServer = 
Option(createServerWithListenerOnPort(serverSocket.getLocalPort)),
+        "Exepected RuntimeException because of KafkaServer startup failure due 
do address already in use"

Review Comment:
   fixed and rephrased, thanks



-- 
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