TaiJuWu commented on code in PR #21126:
URL: https://github.com/apache/kafka/pull/21126#discussion_r2657006733
##########
clients/src/main/java/org/apache/kafka/common/requests/OffsetsForLeaderEpochRequest.java:
##########
@@ -51,10 +52,23 @@ public static Builder
forConsumer(OffsetForLeaderTopicCollection epochsByPartiti
// to clients. Beginning with version 3, the broker requires only
TOPIC Describe
// permission for the topic of each requested partition. In order
to ensure client
// compatibility, we only send this request when we can guarantee
the relaxed permissions.
+
+ // Check if all topics have topic IDs. If so, we can use version 5
which requires topic IDs.
+ // Otherwise, use version 4 which uses topic names.
+ boolean canUseTopicId = true;
+ for (OffsetForLeaderEpochRequestData.OffsetForLeaderTopic topic :
epochsByPartition) {
+ if (topic.topicId() == null ||
topic.topicId().equals(Uuid.ZERO_UUID)) {
+ canUseTopicId = false;
+ break;
+ }
+ }
+
OffsetForLeaderEpochRequestData data = new
OffsetForLeaderEpochRequestData();
data.setReplicaId(CONSUMER_REPLICA_ID);
data.setTopics(epochsByPartition);
- return new Builder((short) 3,
ApiKeys.OFFSET_FOR_LEADER_EPOCH.latestVersion(), data);
+
+ short latestVersion = canUseTopicId ?
ApiKeys.OFFSET_FOR_LEADER_EPOCH.latestVersion() : (short) 4;
Review Comment:
The `OFFSET_FOR_LEADER_EPOCH` is generated so it will be automatically
update when we bump json file.
If you clean build, I think it will be updated.
`short latestVersion =
ApiKeys.OFFSET_FOR_LEADER_EPOCH.latestVersion(canUseTopic);` seems not correct
because the parameter is UnstableVersion but it is different things with
topicId.
If there is any mistake, please correct me.
--
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]