diff --git a/core/src/test/scala/unit/kafka/server/MetadataRequestTest.scala b/core/src/test/scala/unit/kafka/server/MetadataRequestTest.scala index 599ae179ff63..ecb3f7e3af8f 100644 --- a/core/src/test/scala/unit/kafka/server/MetadataRequestTest.scala +++ b/core/src/test/scala/unit/kafka/server/MetadataRequestTest.scala @@ -274,7 +274,7 @@ class MetadataRequestTest extends BaseRequestTest { val serverId = server.dataPlaneRequestProcessor.brokerId val leaderId = partitionMetadata.leaderId val replicaIds = partitionMetadata.replicaIds.asScala - serverId != leaderId && replicaIds.contains(serverId) + leaderId.isPresent && leaderId.get() != serverId && replicaIds.contains(serverId) }.get downNode.shutdown()