You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by GitBox <gi...@apache.org> on 2019/05/08 15:28:01 UTC
[GitHub] [sling-org-apache-sling-distribution-journal-kafka] cschneider
commented on a change in pull request #4: SLING-8409 - Improve test coverage
cschneider commented on a change in pull request #4: SLING-8409 - Improve test coverage
URL: https://github.com/apache/sling-org-apache-sling-distribution-journal-kafka/pull/4#discussion_r282120063
##########
File path: src/main/java/org/apache/sling/distribution/journal/kafka/KafkaClientProvider.java
##########
@@ -150,37 +152,45 @@ public Closeable createPoller(String topicName, Reset reset, @Nullable String as
@Override
public void assertTopic(String topic) throws MessagingException {
- String consumerGroupId = UUID.randomUUID().toString();
- try (KafkaConsumer<String, String> consumer = new KafkaConsumer<>(consumerConfig(StringDeserializer.class, consumerGroupId, Reset.latest))) {
- if (! consumer.listTopics().containsKey(topic)) {
- throw new MessagingException(format("Topic %s does not exist", topic));
- }
+ Map<String, List<PartitionInfo>> topics;
+ try (KafkaConsumer<String, String> consumer = createConsumer(StringDeserializer.class, Reset.latest)) {
+ topics = consumer.listTopics();
} catch (Exception e) {
throw new MessagingException(format("Unable to load topic stats for %s", topic), e);
}
+ if (! topics.containsKey(topic)) {
Review comment:
Moving this outside the try catch avoids rewrapping MessageException
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services