tombentley commented on code in PR #11478:
URL: https://github.com/apache/kafka/pull/11478#discussion_r923431888


##########
core/src/test/scala/unit/kafka/server/KafkaConfigTest.scala:
##########
@@ -206,6 +206,39 @@ class KafkaConfigTest {
     assertBadConfigContainingMessage(props, "Each listener must have a 
different name")
   }
 
+  @Test
+  def testIPv4AndIPv6SamePortListeners(): Unit = {
+    val props = new Properties()
+    props.put(KafkaConfig.BrokerIdProp, "1")
+    props.put(KafkaConfig.ZkConnectProp, "localhost:2181")
+
+    props.put(KafkaConfig.ListenersProp, 
"PLAINTEXT://[::1]:9092,PLAINTEXT://[::1]:9092")
+    var caught = assertThrows(classOf[IllegalArgumentException], () => 
KafkaConfig.fromProps(props))
+    assertTrue(caught.getMessage.contains("If you have two listeners on the 
same port then one needs to be IPv4 and the other IPv6"))
+
+    props.put(KafkaConfig.ListenersProp, 
"PLAINTEXT://127.0.0.1:9092,PLAINTEXT://127.0.0.1:9092")
+    caught = assertThrows(classOf[IllegalArgumentException], () => 
KafkaConfig.fromProps(props))
+    assertTrue(caught.getMessage.contains("If you have two listeners on the 
same port then one needs to be IPv4 and the other IPv6"))
+
+    props.put(KafkaConfig.ListenersProp, 
"PLAINTEXT://127.0.0.1:9092,PLAINTEXT://127.0.0.1:9092,PLAINTEXT://127.0.0.1:9092")
+    caught = assertThrows(classOf[IllegalArgumentException], () => 
KafkaConfig.fromProps(props))
+    assertTrue(caught.getMessage.contains("Each listener must have a different 
name"))

Review Comment:
   That message is fine. 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