This repository has been archived by the owner on Jan 24, 2024. It is now read-only.
Fix wrong semantics and usage of KafkaTopicManager#getTopic #473
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Many usages of
KafkaTopicManager#getTopic
are wrong because they didn't check null value so that NPE may happen. And the semantics ofKafkaTopicManager#getTopic
is wrong because thecreateIfMissing
argument ofBrokerService#getTopic
is true, so if a not existed topic's name was accepted as the argument, the topic would be created automatically. This behavior is unexpected because we only want to create topics automatically inMETADATA
request handler.Modifications
KafkaTopicManager#getTopic
, whenBrokerService#getTopic
is completed exceptionally, returns an exceptionally completed future instead of a null completed future.whenComplete
for allgetTopic
references so that we can handle null completed futures and exceptionally completed futures.LIST_OFFSET
request handler is modified according to the above changesgetTopic
future, return the thrown exception.getTopic
future, return theUNKNOWN_TOPIC_OR_PARTITION
error.ctx
ofKafkaRequestHandler
is null and may cause NPE during error logging, we also set a mockedChannelHandlerContext
in the test.MessageFetchContext#handleFetch
since we've already added logs to the case that the future ofKafkaTopicConsumerManager
is completed exceptionally.