This is an automated email from the ASF dual-hosted git repository.

chia7712 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new f6136a17dd2 KAFKA-20080 Add test case for duplicate ports with 
different hostnames in KafkaConfigTest (#21356)
f6136a17dd2 is described below

commit f6136a17dd267f50650f62424a47e5f4dc03944d
Author: Parker Chang <[email protected]>
AuthorDate: Mon Jan 26 22:05:01 2026 +0800

    KAFKA-20080 Add test case for duplicate ports with different hostnames in 
KafkaConfigTest (#21356)
    
    ### Description
    As described in
    [KAFKA-20080](https://issues.apache.org/jira/browse/KAFKA-20080), the
    configuration "PLAINTEXT://host1:9092,SSL://host2:9092" should fail
    validation due to duplicate ports, but we currently lack a unit test for
    this specific case.
    
    This PR adds the missing test case to `KafkaConfigTest`.
    
    ### Verification
    Ran the specific test using Gradle:
    `./gradlew :core:test --tests
    "kafka.server.KafkaConfigTest.testDuplicateListeners"`
    
    **Output:**
    ```
    Gradle Test Run :core:test > Gradle Test Executor 3 > KafkaConfigTest > 
testDuplicateListeners() PASSED
    ```
    
    Reviewers: Ken Huang <[email protected]>, Chia-Ping Tsai
    <[email protected]>
---
 core/src/test/scala/unit/kafka/server/KafkaConfigTest.scala | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/core/src/test/scala/unit/kafka/server/KafkaConfigTest.scala 
b/core/src/test/scala/unit/kafka/server/KafkaConfigTest.scala
index 2b1830e136d..e34a2a85fd2 100755
--- a/core/src/test/scala/unit/kafka/server/KafkaConfigTest.scala
+++ b/core/src/test/scala/unit/kafka/server/KafkaConfigTest.scala
@@ -211,6 +211,10 @@ class KafkaConfigTest {
     props.setProperty(SocketServerConfigs.LISTENERS_CONFIG, 
"PLAINTEXT://localhost:9091,SSL://localhost:9091")
     assertBadConfigContainingMessage(props, "Each listener must have a 
different port")
 
+    // listeners with duplicate port but different hostnames
+    props.setProperty(SocketServerConfigs.LISTENERS_CONFIG, 
"PLAINTEXT://host1:9092,SSL://host2:9092")
+    assertBadConfigContainingMessage(props, "Each listener must have a 
different port")
+
     // listeners with duplicate name
     props.setProperty(SocketServerConfigs.LISTENERS_CONFIG, 
"PLAINTEXT://localhost:9091,PLAINTEXT://localhost:9092")
     assertBadConfigContainingMessage(props, "Each listener must have a 
different name")

Reply via email to