Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KAFKA-6418: AdminClient should handle empty or null topic names better #4470

Merged
merged 1 commit into from Jan 30, 2018

Conversation

cmccabe
Copy link
Contributor

@cmccabe cmccabe commented Jan 24, 2018

AdminClient should return an InvalidTopicException when the topic name supplied by an AC user is empty or null. Previously, the client would try to serialize these invalid topic names, and the whole batch request would fail, including unrelated topics. Also add a unit test.

@norwood
Copy link
Contributor

norwood commented Jan 24, 2018

🖤

@cmccabe
Copy link
Contributor Author

cmccabe commented Jan 24, 2018

Test failure is org.apache.kafka.streams.integration.ResetIntegrationTest, not related

@cmccabe
Copy link
Contributor Author

cmccabe commented Jan 24, 2018

Retest this please

Copy link
Contributor

@hachikuji hachikuji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch.

if (!topicFutures.containsKey(topicName)) {
if (topicNameIsUnrepresentable(topicName)) {
KafkaFutureImpl<TopicDescription> future = new KafkaFutureImpl<TopicDescription>();
future.completeExceptionally(new InvalidTopicException("The given topic name cannot be " +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May as well add topicName to the message so that the user knows which case they've hit? Same for the others.

env.kafkaClient().prepareMetadataUpdate(env.cluster(), Collections.<String>emptySet());
env.kafkaClient().setNode(env.cluster().controller());

List<String> sillyTopicNames = new ArrayList<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Arrays.asList a bit more concise.

@@ -215,6 +215,41 @@ public void testCreateTopics() throws Exception {
}
}

@Test
public void testInvalidTopicNames() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit (open to discussion): I tend to prefer smaller test cases when they are possible since it is easier to narrow down the problem. Any reason not to split this into 3 separate cases: one for each API?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just more boilerplate creating each test. This particular test actually runs very fast since it's a true unit test (no brokers running), so test time should not be an issue. I don't feel strongly about it, though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't feel too strongly in this case. The advantage generally is that the scope of the test case is clearer which makes failures easier to investigate.

@cmccabe
Copy link
Contributor Author

cmccabe commented Jan 29, 2018

retest this please

Copy link
Contributor

@hachikuji hachikuji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hachikuji hachikuji merged commit ef93998 into apache:trunk Jan 30, 2018
@cmccabe cmccabe deleted the KAFKA-6418 branch May 20, 2019 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants