showuon commented on code in PR #15530: URL: https://github.com/apache/kafka/pull/15530#discussion_r1528015868
########## 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: nit: typo for `Expected`, `due to`. And the sentence could be rephrased, maybe: "Expected RuntimeException due to address already in use when KafkaServer startup" -- 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