Github user srdo commented on a diff in the pull request:
https://github.com/apache/storm/pull/2755#discussion_r200959509
--- Diff:
external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/NamedTopicFilter.java
---
@@ -54,8 +57,12 @@ public NamedTopicFilter(String... topics) {
public List<TopicPartition>
getFilteredTopicPartitions(KafkaConsumer<?, ?> consumer) {
List<TopicPartition> allPartitions = new ArrayList<>();
for (String topic : topics) {
- for (PartitionInfo partitionInfo:
consumer.partitionsFor(topic)) {
- allPartitions.add(new
TopicPartition(partitionInfo.topic(), partitionInfo.partition()));
+ if(consumer.partitionsFor(topic) != null) {
--- End diff --
Whether it inlines the method or not, the code is still executed twice.
Besides, extracting to a variable means we don't have to worry about stuff like
someone making a change to one call and not another, and it makes the code less
noisy.
---