RamanVerma opened a new pull request #9112: URL: https://github.com/apache/kafka/pull/9112
MetadataCache#getPartitionMetadata returns an error when the topic's leader Id is present at MetadataCache but listener endpoint is not present for this leader. For older version, LEADER_NOT_AVAILABLE is returned while LISTENER_NOT_FOUND is returned for new metadata version. getPartitionMetadata was looking up MetadataCache's host brokerId rather than the topic's leader id while determining what error to return. This could result in the call returning LISTENER_NOT_FOUND when it should have returned LEADER_NOT_AVAILABLE. This commit corrects this behavior. Unit tests were already present to test out the error codes returned under different situations but they were giving out a false positive. The test was using same broker id for both the MetadataCache's host as well as for the topic's leader. Error manifests when the MetadataCache's host id is changed. Improved the test. This commit also consolidated couple of related tests to reduce code duplication. *More detailed description of your change, if necessary. The PR title and PR message become the squashed commit message, so use a separate comment to ping reviewers.* *Summary of testing strategy (including rationale) for the feature or bug fix. Unit and/or integration tests are expected for any behaviour change and system tests should be considered for larger changes.* ### Committer Checklist (excluded from commit message) - [ ] Verify design and implementation - [ ] Verify test coverage and CI build status - [ ] Verify documentation (including upgrade notes) ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org