Igor Soarez created KAFKA-20558:
-----------------------------------
Summary: NPE in ClusterInstance.waitUntilLeaderIsElectedOrChanged
causes flaky tests
Key: KAFKA-20558
URL: https://issues.apache.org/jira/browse/KAFKA-20558
Project: Kafka
Issue Type: Test
Components: system tests
Reporter: Igor Soarez
{{topicPartitionInfo.leader()}} [may return
null|[http://example.com|https://github.com/apache/kafka/blob/351a8b20da360f1073569a9cdfcd7f418fd50fe9/clients/src/main/java/org/apache/kafka/common/TopicPartitionInfo.java#L79-L84]],
but {{ClusterInstance}} [does not check for
null|https://github.com/apache/kafka/blob/29d0ec207ef15bf4ca3f869c64da2a3586d6ac13/test-common/test-common-runtime/src/main/java/org/apache/kafka/common/test/ClusterInstance.java#L436].
Spotted in [test
results|https://github.com/apache/kafka/actions/runs/25470870336/job/74734800997?pr=20376],
e.g. org.apache.kafka.tools.LeaderElectionCommandTest:
{code:java}
java.lang.NullPointerException: Cannot invoke
"org.apache.kafka.common.Node.id()" because the return value of
"org.apache.kafka.common.TopicPartitionInfo.leader()" is null
at
org.apache.kafka.common.test.ClusterInstance.lambda$waitUntilLeaderIsElectedOrChangedWithAdmin$1(ClusterInstance.java:438)
at java.base/java.util.Optional.map(Optional.java:260)
at
org.apache.kafka.common.test.ClusterInstance.waitUntilLeaderIsElectedOrChangedWithAdmin(ClusterInstance.java:437)
at
org.apache.kafka.tools.LeaderElectionCommandTest.assertLeader(LeaderElectionCommandTest.java:449)
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)