Skip to content

Conversation

TaiJuWu
Copy link
Collaborator

@TaiJuWu TaiJuWu commented Sep 22, 2025

Migrate listenerListToEndPoints from CoreUtils to AbstractKafkaConfig

@github-actions github-actions bot added triage PRs from the community core Kafka Broker build Gradle build or GitHub Actions labels Sep 22, 2025
@TaiJuWu TaiJuWu force-pushed the absCOnfig branch 3 times, most recently from a2fe028 to 6c1d6a3 Compare September 22, 2025 02:44
@TaiJuWu TaiJuWu marked this pull request as ready for review September 22, 2025 03:26
@TaiJuWu TaiJuWu changed the title MINOR: migrate listenerListToEndPoints from CoreUtils to AbstractKafkaConfig (WIP) MINOR: migrate listenerListToEndPoints from CoreUtils to AbstractKafkaConfig Sep 22, 2025
@TaiJuWu TaiJuWu changed the title (WIP) MINOR: migrate listenerListToEndPoints from CoreUtils to AbstractKafkaConfig MINOR: migrate listenerListToEndPoints from CoreUtils to AbstractKafkaConfig Sep 22, 2025
if (distinctListenerNames != endPoints.size()) {
throw new IllegalArgumentException("Each listener must have a different name, listeners: " + listeners);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can return early if requireDistinctPorts is false, right? for example:

private static void validate(List<Endpoint> endPoints, List<String> listeners, boolean requireDistinctPorts) {
    long distinct = endPoints.stream().map(Endpoint::listener).distinct().count();
    if (distinct != endPoints.size()) {
        throw new IllegalArgumentException("Each listener must have a different name, listeners: " + listeners);
    }

    if (!requireDistinctPorts) return;

  ...

@github-actions github-actions bot removed the triage PRs from the community label Sep 25, 2025
List<Endpoint> duplicatesWithIpHosts = partitionedByValidIp.get(true);
List<Endpoint> duplicatesWithoutIpHosts = partitionedByValidIp.get(false);

if (requireDistinctPorts) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requireDistinctPorts is always false, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, thanks.

assertEquals(listenerListToEndPoints(util.List.of("PLAINTEXT://:9092")).asScala, conf.listeners)
assertNull(conf.listeners.find(_.securityProtocol == SecurityProtocol.PLAINTEXT).get.host)
assertEquals(conf.effectiveAdvertisedBrokerListeners, listenerListToEndPoints(util.List.of("PLAINTEXT://:9092")))
assertEquals(conf.effectiveAdvertisedBrokerListeners, listenerListToEndPoints(util.List.of("PLAINTEXT://:9092")).asScala)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be in reverse order.

Suggested change
assertEquals(conf.effectiveAdvertisedBrokerListeners, listenerListToEndPoints(util.List.of("PLAINTEXT://:9092")).asScala)
assertEquals(listenerListToEndPoints(util.List.of("PLAINTEXT://:9092")).asScala, conf.effectiveAdvertisedBrokerListeners))

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Gradle build or GitHub Actions core Kafka Broker
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants