Skip to content

KAFKA-12702: Fix NPE in networkListeners from BrokerServer#10575

Merged
chia7712 merged 3 commits intoapache:trunkfrom
wenbingshen:KAFKA-12702
Apr 22, 2021
Merged

KAFKA-12702: Fix NPE in networkListeners from BrokerServer#10575
chia7712 merged 3 commits intoapache:trunkfrom
wenbingshen:KAFKA-12702

Conversation

@wenbingshen
Copy link
Copy Markdown
Member

According to the comments in the configuration file (config/kraft/server.properties), if listeners and advertised.listeners are not configured with an address, the program will automatically obtain java.net.InetAddress.getCanonicalHostName(), but this will actually cause the service to fail to start. Because the host parameter value of Listener in BrokerRegistrationRequestData will be null.
For more information stack, can link to this jiraId to view: KAFKA-12702

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

Copy link
Copy Markdown
Member

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

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

@wenbingshen nice find! one comment below.

config.advertisedListeners.foreach { ep =>
networkListeners.add(new Listener().
setHost(ep.host).
setHost(if (ep.host == null || ep.host.trim.isEmpty) InetAddress.getLocalHost.getCanonicalHostName else ep.host).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you use Utils.isBlank(ep.host)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good idea.Thank you for your guidance and submit your feedback. :)

@chia7712
Copy link
Copy Markdown
Member

@wenbingshen As Utils.isBlank(ep.host) does not exist in 2.8, could you file another PR for 2.8 branch?

@wenbingshen
Copy link
Copy Markdown
Member Author

@wenbingshen As Utils.isBlank(ep.host) does not exist in 2.8, could you file another PR for 2.8 branch?

Of course, I will do it now, thank you for your guidance. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants