dajac commented on code in PR #21809:
URL: https://github.com/apache/kafka/pull/21809#discussion_r2954882887
##########
core/src/main/scala/kafka/server/KafkaApis.scala:
##########
@@ -313,8 +313,13 @@ class KafkaApis(val requestChannel: RequestChannel,
// For lower API versions, the topic id may not be included in the
request.
// In this case, we resolve the topic id from metadata cache to
ensure that the topic exists.
// If the topic doesn't exist, the currentTopicId will fallback to
ZERO_UUID.
- val currentTopicId = metadataCache.getTopicId(topic.name)
- topic.setTopicId(currentTopicId)
+ val currentTopicId = if (topic.topicId != Uuid.ZERO_UUID) {
+ topic.topicId
+ } else {
+ val resolvedTopicId = metadataCache.getTopicId(topic.name)
+ if (resolvedTopicId != Uuid.ZERO_UUID)
topic.setTopicId(resolvedTopicId)
+ resolvedTopicId
+ }
Review Comment:
It seems that we could just drop `currentTopicId`.
```
if (!useTopicIds) {
topic.setTopicId(metadataCache.getTopicId(topic.name))
}
if (topic.topicId == Uuid.ZERO_UUID) {
...
```
Would something like this work?
--
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]