Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-6079

Ineffective null check in FlinkKafkaConsumerBase#open()

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.3.0
    • Component/s: Kafka Connector
    • Labels:
      None

      Description

      Here is related code:

          List<KafkaTopicPartition> kafkaTopicPartitions = getKafkaPartitions(topics);
      
          subscribedPartitionsToStartOffsets = new HashMap<>(kafkaTopicPartitions.size());
      
          if (kafkaTopicPartitions != null) {
      

      Prior to the null check, kafkaTopicPartitions is already dereferenced.

        Issue Links

          Activity

          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user zentol opened a pull request:

          https://github.com/apache/flink/pull/3685

          FLINK-6079 [kafka] Provide meaningful error message if TopicPartitions are null

          This PR verifies that the List of topicPartitions returned by the `FlinKKafkaConsumerBase#getKafkaPartitions()` isn't null. I'm assuming this only happens when a sub-class isn't implemented correctly, as all implementations pass a non-null list. (Even the dummies pass an empty list)

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/zentol/flink 6079_kafka_bull

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/flink/pull/3685.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #3685


          commit 29d59776e2fdd626be0a9315aa79f5c08a25bb58
          Author: zentol <chesnay@apache.org>
          Date: 2017-04-06T09:55:29Z

          FLINK-6079 [kafka] Provide meaningful error message if TopicPartitions are null


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user zentol opened a pull request: https://github.com/apache/flink/pull/3685 FLINK-6079 [kafka] Provide meaningful error message if TopicPartitions are null This PR verifies that the List of topicPartitions returned by the `FlinKKafkaConsumerBase#getKafkaPartitions()` isn't null. I'm assuming this only happens when a sub-class isn't implemented correctly, as all implementations pass a non-null list. (Even the dummies pass an empty list) You can merge this pull request into a Git repository by running: $ git pull https://github.com/zentol/flink 6079_kafka_bull Alternatively you can review and apply these changes as the patch at: https://github.com/apache/flink/pull/3685.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #3685 commit 29d59776e2fdd626be0a9315aa79f5c08a25bb58 Author: zentol <chesnay@apache.org> Date: 2017-04-06T09:55:29Z FLINK-6079 [kafka] Provide meaningful error message if TopicPartitions are null
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user tzulitai commented on the issue:

          https://github.com/apache/flink/pull/3685

          Thanks for the PR! I think #3476 solves this indirectly also, but it would make sense to fix the issue with this PR first as #3476 still needs some time and massaging.

          LGTM, definitely an improvement to guard against subclass implementations. +1.

          Show
          githubbot ASF GitHub Bot added a comment - Github user tzulitai commented on the issue: https://github.com/apache/flink/pull/3685 Thanks for the PR! I think #3476 solves this indirectly also, but it would make sense to fix the issue with this PR first as #3476 still needs some time and massaging. LGTM, definitely an improvement to guard against subclass implementations. +1.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user zentol commented on the issue:

          https://github.com/apache/flink/pull/3685

          merging.

          Show
          githubbot ASF GitHub Bot added a comment - Github user zentol commented on the issue: https://github.com/apache/flink/pull/3685 merging.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/flink/pull/3685

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/flink/pull/3685
          Hide
          Zentol Chesnay Schepler added a comment -

          1.3: 8890a8db41c45504aa658a1942f40bb9af7dcf30

          Show
          Zentol Chesnay Schepler added a comment - 1.3: 8890a8db41c45504aa658a1942f40bb9af7dcf30

            People

            • Assignee:
              Zentol Chesnay Schepler
              Reporter:
              yuzhihong@gmail.com Ted Yu
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development