mdedetrich commented on code in PR #11478: URL: https://github.com/apache/kafka/pull/11478#discussion_r923354559
########## 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: So the full error message is actually ``` Each listener must have a different name unless you have exactly one listener on IPv4 and the other IPv6 on the same port, listeners: $listeners" ``` I was just lazy/forgot and didn't want to put the entire error message line in this test, I can update this if you want. Do you also still want to update the error message to what you suggested? -- 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