Uploaded image for project: 'Hadoop Map/Reduce'
  1. Hadoop Map/Reduce
  2. MAPREDUCE-6535

TaskID default constructor results in NPE on toString()

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.6.0
    • Fix Version/s: 2.9.0, 3.0.0-alpha1
    • Component/s: mrv2
    • Labels:
      None
    • Hadoop Flags:
      Reviewed

      Description

      This code will reproduce the issue:

      new TaskAttemptID().toString();
      

      The issue is that the default constructor leaves the type null. The get() in CharTaskTypesMaps.getRepresentingCharacter() then throws an NPE on the null type key.

      The simplest solution would be to only call the get() on line 288 of TaskID.java if type is not null and return some other literal otherwise. Since no part of the code is tripping on the NPE, what we choose for the literal shouldn't matter. How about "x"?

        Activity

        Hide
        hudson Hudson added a comment -

        FAILURE: Integrated in Hadoop-trunk-Commit #9500 (See https://builds.apache.org/job/Hadoop-trunk-Commit/9500/)
        MAPREDUCE-6535. TaskID default constructor results in NPE on toString(). (jlowe: rev 3f622a143c5fb15fee7e5dded99e4a4136f19810)

        • hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/TaskID.java
        • hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/TestTaskID.java
        Show
        hudson Hudson added a comment - FAILURE: Integrated in Hadoop-trunk-Commit #9500 (See https://builds.apache.org/job/Hadoop-trunk-Commit/9500/ ) MAPREDUCE-6535 . TaskID default constructor results in NPE on toString(). (jlowe: rev 3f622a143c5fb15fee7e5dded99e4a4136f19810) hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/TaskID.java hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/TestTaskID.java
        Hide
        jlowe Jason Lowe added a comment -

        Thanks to Daniel Templeton for the contribution and to zhihai xu and Rakesh for additional review! I committed this to trunk and branch-2.

        Show
        jlowe Jason Lowe added a comment - Thanks to Daniel Templeton for the contribution and to zhihai xu and Rakesh for additional review! I committed this to trunk and branch-2.
        Hide
        jlowe Jason Lowe added a comment -

        +1 lgtm. Will commit tomorrow if there are no objections.

        Show
        jlowe Jason Lowe added a comment - +1 lgtm. Will commit tomorrow if there are no objections.
        Hide
        hadoopqa Hadoop QA added a comment -
        +1 overall



        Vote Subsystem Runtime Comment
        0 reexec 0m 11s Docker mode activated.
        +1 @author 0m 0s The patch does not contain any @author tags.
        +1 test4tests 0m 0s The patch appears to include 1 new or modified test files.
        +1 mvninstall 6m 54s trunk passed
        +1 compile 0m 24s trunk passed with JDK v1.8.0_74
        +1 compile 0m 24s trunk passed with JDK v1.7.0_95
        +1 checkstyle 0m 17s trunk passed
        +1 mvnsite 0m 30s trunk passed
        +1 mvneclipse 0m 13s trunk passed
        +1 findbugs 1m 4s trunk passed
        +1 javadoc 0m 22s trunk passed with JDK v1.8.0_74
        +1 javadoc 0m 25s trunk passed with JDK v1.7.0_95
        +1 mvninstall 0m 24s the patch passed
        +1 compile 0m 19s the patch passed with JDK v1.8.0_74
        -1 javac 2m 46s hadoop-mapreduce-project_hadoop-mapreduce-client_hadoop-mapreduce-client-core-jdk1.8.0_74 with JDK v1.8.0_74 generated 3 new + 136 unchanged - 0 fixed = 139 total (was 136)
        +1 javac 0m 19s the patch passed
        +1 compile 0m 22s the patch passed with JDK v1.7.0_95
        -1 javac 3m 8s hadoop-mapreduce-project_hadoop-mapreduce-client_hadoop-mapreduce-client-core-jdk1.7.0_95 with JDK v1.7.0_95 generated 3 new + 139 unchanged - 0 fixed = 142 total (was 139)
        +1 javac 0m 22s the patch passed
        +1 checkstyle 0m 15s hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core: patch generated 0 new + 13 unchanged - 6 fixed = 13 total (was 19)
        +1 mvnsite 0m 29s the patch passed
        +1 mvneclipse 0m 12s the patch passed
        +1 whitespace 0m 0s Patch has no whitespace issues.
        +1 findbugs 1m 12s the patch passed
        +1 javadoc 0m 19s the patch passed with JDK v1.8.0_74
        +1 javadoc 0m 22s the patch passed with JDK v1.7.0_95
        +1 unit 1m 52s hadoop-mapreduce-client-core in the patch passed with JDK v1.8.0_74.
        +1 unit 2m 16s hadoop-mapreduce-client-core in the patch passed with JDK v1.7.0_95.
        +1 asflicense 0m 19s Patch does not generate ASF License warnings.
        20m 5s



        Subsystem Report/Notes
        Docker Image:yetus/hadoop:fbe3e86
        JIRA Patch URL https://issues.apache.org/jira/secure/attachment/12794809/MAPREDUCE-6535.001.patch
        JIRA Issue MAPREDUCE-6535
        Optional Tests asflicense compile javac javadoc mvninstall mvnsite unit findbugs checkstyle
        uname Linux 4130b0bd094c 3.13.0-36-lowlatency #63-Ubuntu SMP PREEMPT Wed Sep 3 21:56:12 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
        Build tool maven
        Personality /testptch/hadoop/patchprocess/precommit/personality/provided.sh
        git revision trunk / e7ed05e
        Default Java 1.7.0_95
        Multi-JDK versions /usr/lib/jvm/java-8-oracle:1.8.0_74 /usr/lib/jvm/java-7-openjdk-amd64:1.7.0_95
        findbugs v3.0.0
        javac hadoop-mapreduce-project_hadoop-mapreduce-client_hadoop-mapreduce-client-core-jdk1.8.0_74: https://builds.apache.org/job/PreCommit-MAPREDUCE-Build/6389/artifact/patchprocess/diff-compile-javac-hadoop-mapreduce-project_hadoop-mapreduce-client_hadoop-mapreduce-client-core-jdk1.8.0_74.txt
        javac hadoop-mapreduce-project_hadoop-mapreduce-client_hadoop-mapreduce-client-core-jdk1.7.0_95: https://builds.apache.org/job/PreCommit-MAPREDUCE-Build/6389/artifact/patchprocess/diff-compile-javac-hadoop-mapreduce-project_hadoop-mapreduce-client_hadoop-mapreduce-client-core-jdk1.7.0_95.txt
        JDK v1.7.0_95 Test Results https://builds.apache.org/job/PreCommit-MAPREDUCE-Build/6389/testReport/
        modules C: hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core U: hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core
        Console output https://builds.apache.org/job/PreCommit-MAPREDUCE-Build/6389/console
        Powered by Apache Yetus 0.2.0 http://yetus.apache.org

        This message was automatically generated.

        Show
        hadoopqa Hadoop QA added a comment - +1 overall Vote Subsystem Runtime Comment 0 reexec 0m 11s Docker mode activated. +1 @author 0m 0s The patch does not contain any @author tags. +1 test4tests 0m 0s The patch appears to include 1 new or modified test files. +1 mvninstall 6m 54s trunk passed +1 compile 0m 24s trunk passed with JDK v1.8.0_74 +1 compile 0m 24s trunk passed with JDK v1.7.0_95 +1 checkstyle 0m 17s trunk passed +1 mvnsite 0m 30s trunk passed +1 mvneclipse 0m 13s trunk passed +1 findbugs 1m 4s trunk passed +1 javadoc 0m 22s trunk passed with JDK v1.8.0_74 +1 javadoc 0m 25s trunk passed with JDK v1.7.0_95 +1 mvninstall 0m 24s the patch passed +1 compile 0m 19s the patch passed with JDK v1.8.0_74 -1 javac 2m 46s hadoop-mapreduce-project_hadoop-mapreduce-client_hadoop-mapreduce-client-core-jdk1.8.0_74 with JDK v1.8.0_74 generated 3 new + 136 unchanged - 0 fixed = 139 total (was 136) +1 javac 0m 19s the patch passed +1 compile 0m 22s the patch passed with JDK v1.7.0_95 -1 javac 3m 8s hadoop-mapreduce-project_hadoop-mapreduce-client_hadoop-mapreduce-client-core-jdk1.7.0_95 with JDK v1.7.0_95 generated 3 new + 139 unchanged - 0 fixed = 142 total (was 139) +1 javac 0m 22s the patch passed +1 checkstyle 0m 15s hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core: patch generated 0 new + 13 unchanged - 6 fixed = 13 total (was 19) +1 mvnsite 0m 29s the patch passed +1 mvneclipse 0m 12s the patch passed +1 whitespace 0m 0s Patch has no whitespace issues. +1 findbugs 1m 12s the patch passed +1 javadoc 0m 19s the patch passed with JDK v1.8.0_74 +1 javadoc 0m 22s the patch passed with JDK v1.7.0_95 +1 unit 1m 52s hadoop-mapreduce-client-core in the patch passed with JDK v1.8.0_74. +1 unit 2m 16s hadoop-mapreduce-client-core in the patch passed with JDK v1.7.0_95. +1 asflicense 0m 19s Patch does not generate ASF License warnings. 20m 5s Subsystem Report/Notes Docker Image:yetus/hadoop:fbe3e86 JIRA Patch URL https://issues.apache.org/jira/secure/attachment/12794809/MAPREDUCE-6535.001.patch JIRA Issue MAPREDUCE-6535 Optional Tests asflicense compile javac javadoc mvninstall mvnsite unit findbugs checkstyle uname Linux 4130b0bd094c 3.13.0-36-lowlatency #63-Ubuntu SMP PREEMPT Wed Sep 3 21:56:12 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux Build tool maven Personality /testptch/hadoop/patchprocess/precommit/personality/provided.sh git revision trunk / e7ed05e Default Java 1.7.0_95 Multi-JDK versions /usr/lib/jvm/java-8-oracle:1.8.0_74 /usr/lib/jvm/java-7-openjdk-amd64:1.7.0_95 findbugs v3.0.0 javac hadoop-mapreduce-project_hadoop-mapreduce-client_hadoop-mapreduce-client-core-jdk1.8.0_74: https://builds.apache.org/job/PreCommit-MAPREDUCE-Build/6389/artifact/patchprocess/diff-compile-javac-hadoop-mapreduce-project_hadoop-mapreduce-client_hadoop-mapreduce-client-core-jdk1.8.0_74.txt javac hadoop-mapreduce-project_hadoop-mapreduce-client_hadoop-mapreduce-client-core-jdk1.7.0_95: https://builds.apache.org/job/PreCommit-MAPREDUCE-Build/6389/artifact/patchprocess/diff-compile-javac-hadoop-mapreduce-project_hadoop-mapreduce-client_hadoop-mapreduce-client-core-jdk1.7.0_95.txt JDK v1.7.0_95 Test Results https://builds.apache.org/job/PreCommit-MAPREDUCE-Build/6389/testReport/ modules C: hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core U: hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core Console output https://builds.apache.org/job/PreCommit-MAPREDUCE-Build/6389/console Powered by Apache Yetus 0.2.0 http://yetus.apache.org This message was automatically generated.
        Hide
        templedf Daniel Templeton added a comment -

        This patch sets the default task type to REDUCE. It also fixes all the javadocs and add a full set of unit tests.

        Show
        templedf Daniel Templeton added a comment - This patch sets the default task type to REDUCE. It also fixes all the javadocs and add a full set of unit tests.
        Hide
        rakesh_techie Rakesh added a comment -

        I agree with above solution to make it default to TaskType.REDUCE as we found this issue in reduce phase while creating custom output format to create different directories based on the key.

        Thanks for prompt response on this. Please let me know if I can provide a fix on this.

        Show
        rakesh_techie Rakesh added a comment - I agree with above solution to make it default to TaskType.REDUCE as we found this issue in reduce phase while creating custom output format to create different directories based on the key. Thanks for prompt response on this. Please let me know if I can provide a fix on this.
        Hide
        zxu zhihai xu added a comment -

        +1 to use TaskType.REDUCE as the default task type and make it compatible with MR1.

        Show
        zxu zhihai xu added a comment - +1 to use TaskType.REDUCE as the default task type and make it compatible with MR1.
        Hide
        templedf Daniel Templeton added a comment -

        I had considered that, but I thought it might violate the principle of least astonishment. If that was the effective behavior in MR1, then that's probably the best approach.

        Show
        templedf Daniel Templeton added a comment - I had considered that, but I thought it might violate the principle of least astonishment. If that was the effective behavior in MR1, then that's probably the best approach.
        Hide
        jlowe Jason Lowe added a comment -

        It works in MR1.

        I was surprised by that, so I went looking at how it would end up working in MR1. That code basically defaults to a reducer with ID 0 since it has a boolean for the type rather than an enum. Seems like we could simply do the same thing and default the task type to TaskType.REDUCE since that's effectively what the old code did as well.

        Show
        jlowe Jason Lowe added a comment - It works in MR1. I was surprised by that, so I went looking at how it would end up working in MR1. That code basically defaults to a reducer with ID 0 since it has a boolean for the type rather than an enum. Seems like we could simply do the same thing and default the task type to TaskType.REDUCE since that's effectively what the old code did as well.
        Hide
        templedf Daniel Templeton added a comment -

        It's a custom OutputFormat that's using the TaskAttemptID to build the output path. It works in MR1.

        I agree that mucking with toString() has the potential to be a can of worms. The other alternative would be to lock down the default constructors in some way so that users know not to use them.

        Show
        templedf Daniel Templeton added a comment - It's a custom OutputFormat that's using the TaskAttemptID to build the output path. It works in MR1. I agree that mucking with toString() has the potential to be a can of worms. The other alternative would be to lock down the default constructors in some way so that users know not to use them.
        Hide
        jlowe Jason Lowe added a comment -

        Curious, what code is trying to print an invalid task attempt ID? The only reason there's a default constructor is so something can call readFields on it. It's not a valid task ID until it's been initialized, and the next step of fixing toString is that the type converters will then say they can't convert the string back into a task attempt ID, etc.

        Show
        jlowe Jason Lowe added a comment - Curious, what code is trying to print an invalid task attempt ID? The only reason there's a default constructor is so something can call readFields on it. It's not a valid task ID until it's been initialized, and the next step of fixing toString is that the type converters will then say they can't convert the string back into a task attempt ID, etc.

          People

          • Assignee:
            templedf Daniel Templeton
            Reporter:
            templedf Daniel Templeton
          • Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development