kevin-wu24 commented on code in PR #22680:
URL: https://github.com/apache/kafka/pull/22680#discussion_r4350257670


##########
metadata/src/test/java/org/apache/kafka/metadata/MetadataCacheTest.java:
##########
@@ -508,6 +504,65 @@ public void 
getAliveBrokersShouldNotBeMutatedByUpdateCache() {
         }
     }
 
+    @Test
+    public void 
testGetPartitionLeaderEndpointForKnownPartitionWithoutEndpoint() {
+        MetadataCache cache = createCache();
+        ListenerName listenerName = 
ListenerName.forSecurityProtocol(SecurityProtocol.PLAINTEXT);
+        String topic = "topic";
+        Uuid topicId = Uuid.randomUuid();
+
+        List<ApiMessage> records = List.of(
+            new RegisterBrokerRecord()
+                .setBrokerId(0)
+                .setBrokerEpoch(BROKER_EPOCH)
+                .setFenced(false)
+                .setEndPoints(new BrokerEndpointCollection(List.of(
+                    new BrokerEndpoint()
+                        .setHost("foo0")
+                        .setPort(9092)
+                        .setSecurityProtocol(SecurityProtocol.PLAINTEXT.id)
+                        .setName(listenerName.value())
+                ))),
+            new TopicRecord().setName(topic).setTopicId(topicId),
+            new PartitionRecord()
+                .setTopicId(topicId)
+                .setPartitionId(0)
+                .setLeader(0)
+                .setLeaderEpoch(0)
+                .setPartitionEpoch(0)
+                .setIsr(List.of(0))
+                .setReplicas(List.of(0)),
+            new PartitionRecord()
+                .setTopicId(topicId)
+                .setPartitionId(1)
+                .setLeader(1)

Review Comment:
   You cannot have a partition that is led by a broker which is unregistered.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to