tzulitai commented on a change in pull request #7487: [FLINK-11321] Clarify NPE 
on fetching nonexistent topic
URL: https://github.com/apache/flink/pull/7487#discussion_r247805112
 
 

 ##########
 File path: 
flink-connectors/flink-connector-kafka-0.9/src/main/java/org/apache/flink/streaming/connectors/kafka/internal/Kafka09PartitionDiscoverer.java
 ##########
 @@ -69,12 +69,18 @@ protected void initializeConnections() {
        }
 
        @Override
-       protected List<KafkaTopicPartition> 
getAllPartitionsForTopics(List<String> topics) throws WakeupException {
+       protected List<KafkaTopicPartition> 
getAllPartitionsForTopics(List<String> topics) throws WakeupException, 
IllegalArgumentException {
                List<KafkaTopicPartition> partitions = new LinkedList<>();
 
                try {
                        for (String topic : topics) {
-                               for (PartitionInfo partitionInfo : 
kafkaConsumer.partitionsFor(topic)) {
+                               List<PartitionInfo> partitions = 
kafkaConsumer.partitionsFor(topic);
+
+                               if (partitions == null) {
+                                       throw new 
IllegalArgumentException("Could not fetch partitions for Topic: 
%s".format(topic));
 
 Review comment:
   Also, would it make more sense to only fail if all topics fail to define 
partitions to consume from?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to