You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/01/15 08:53:56 UTC

[GitHub] tzulitai commented on a change in pull request #7487: [FLINK-11321] Clarify NPE on fetching nonexistent topic

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_r247804786
 
 

 ##########
 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:
   `IllegalArgumentException` doesn't seem right here.
   Maybe just a runtime exception?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services