Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-12859

Disable hiding field style checks in class setters

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.8.0, 3.0.0-alpha1
    • Component/s: None
    • Labels:
      None

      Description

      As discussed in mailing list, this will disable style checks in class setters like the following:

      void setBlockLocations(LocatedBlocks blockLocations) {:42: 'blockLocations' hides a field.
      void setTimeout(int timeout) {:25: 'timeout' hides a field.
      void setLocatedBlocks(List<LocatedBlock> locatedBlocks) {:46: 'locatedBlocks' hides a field.
      void setRemaining(long remaining) {:28: 'remaining' hides a field.
      void setBytesPerCRC(int bytesPerCRC) {:29: 'bytesPerCRC' hides a field.
      void setCrcType(DataChecksum.Type crcType) {:39: 'crcType' hides a field.
      void setCrcPerBlock(long crcPerBlock) {:30: 'crcPerBlock' hides a field.
      void setRefetchBlocks(boolean refetchBlocks) {:35: 'refetchBlocks' hides a field.
      void setLastRetriedIndex(int lastRetriedIndex) {:34: 'lastRetriedIndex' hides a field.
      

        Activity

        Hide
        drankye Kai Zheng added a comment -

        Uploaded a patch to disable the check in setters.

        Show
        drankye Kai Zheng added a comment - Uploaded a patch to disable the check in setters.
        Hide
        hadoopqa Hadoop QA added a comment -
        -1 overall



        Vote Subsystem Runtime Comment
        0 reexec 0m 15s Docker mode activated.
        +1 @author 0m 0s The patch does not contain any @author tags.
        -1 test4tests 0m 0s The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.
        +1 mvninstall 6m 48s trunk passed
        +1 compile 0m 10s trunk passed with JDK v1.8.0_72
        +1 compile 0m 9s trunk passed with JDK v1.7.0_95
        +1 mvnsite 0m 13s trunk passed
        +1 mvneclipse 0m 10s trunk passed
        +1 javadoc 0m 10s trunk passed with JDK v1.8.0_72
        +1 javadoc 0m 10s trunk passed with JDK v1.7.0_95
        +1 mvninstall 0m 8s the patch passed
        +1 compile 0m 5s the patch passed with JDK v1.8.0_72
        +1 javac 0m 5s the patch passed
        +1 compile 0m 6s the patch passed with JDK v1.7.0_95
        +1 javac 0m 6s the patch passed
        +1 mvnsite 0m 8s the patch passed
        +1 mvneclipse 0m 8s the patch passed
        +1 whitespace 0m 0s Patch has no whitespace issues.
        +1 xml 0m 0s The patch has no ill-formed XML file.
        +1 javadoc 0m 6s the patch passed with JDK v1.8.0_72
        +1 javadoc 0m 7s the patch passed with JDK v1.7.0_95
        +1 unit 0m 6s hadoop-build-tools in the patch passed with JDK v1.8.0_72.
        +1 unit 0m 7s hadoop-build-tools in the patch passed with JDK v1.7.0_95.
        +1 asflicense 0m 18s Patch does not generate ASF License warnings.
        10m 13s



        Subsystem Report/Notes
        Docker Image:yetus/hadoop:0ca8df7
        JIRA Patch URL https://issues.apache.org/jira/secure/attachment/12790676/HADOOP-12859-v1.patch
        JIRA Issue HADOOP-12859
        Optional Tests asflicense compile javac javadoc mvninstall mvnsite unit xml
        uname Linux 6ba9a2b9c6ff 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 / d251e55
        Default Java 1.7.0_95
        Multi-JDK versions /usr/lib/jvm/java-8-oracle:1.8.0_72 /usr/lib/jvm/java-7-openjdk-amd64:1.7.0_95
        JDK v1.7.0_95 Test Results https://builds.apache.org/job/PreCommit-HADOOP-Build/8754/testReport/
        modules C: hadoop-build-tools U: hadoop-build-tools
        Console output https://builds.apache.org/job/PreCommit-HADOOP-Build/8754/console
        Powered by Apache Yetus 0.3.0-SNAPSHOT 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 15s Docker mode activated. +1 @author 0m 0s The patch does not contain any @author tags. -1 test4tests 0m 0s The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch. +1 mvninstall 6m 48s trunk passed +1 compile 0m 10s trunk passed with JDK v1.8.0_72 +1 compile 0m 9s trunk passed with JDK v1.7.0_95 +1 mvnsite 0m 13s trunk passed +1 mvneclipse 0m 10s trunk passed +1 javadoc 0m 10s trunk passed with JDK v1.8.0_72 +1 javadoc 0m 10s trunk passed with JDK v1.7.0_95 +1 mvninstall 0m 8s the patch passed +1 compile 0m 5s the patch passed with JDK v1.8.0_72 +1 javac 0m 5s the patch passed +1 compile 0m 6s the patch passed with JDK v1.7.0_95 +1 javac 0m 6s the patch passed +1 mvnsite 0m 8s the patch passed +1 mvneclipse 0m 8s the patch passed +1 whitespace 0m 0s Patch has no whitespace issues. +1 xml 0m 0s The patch has no ill-formed XML file. +1 javadoc 0m 6s the patch passed with JDK v1.8.0_72 +1 javadoc 0m 7s the patch passed with JDK v1.7.0_95 +1 unit 0m 6s hadoop-build-tools in the patch passed with JDK v1.8.0_72. +1 unit 0m 7s hadoop-build-tools in the patch passed with JDK v1.7.0_95. +1 asflicense 0m 18s Patch does not generate ASF License warnings. 10m 13s Subsystem Report/Notes Docker Image:yetus/hadoop:0ca8df7 JIRA Patch URL https://issues.apache.org/jira/secure/attachment/12790676/HADOOP-12859-v1.patch JIRA Issue HADOOP-12859 Optional Tests asflicense compile javac javadoc mvninstall mvnsite unit xml uname Linux 6ba9a2b9c6ff 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 / d251e55 Default Java 1.7.0_95 Multi-JDK versions /usr/lib/jvm/java-8-oracle:1.8.0_72 /usr/lib/jvm/java-7-openjdk-amd64:1.7.0_95 JDK v1.7.0_95 Test Results https://builds.apache.org/job/PreCommit-HADOOP-Build/8754/testReport/ modules C: hadoop-build-tools U: hadoop-build-tools Console output https://builds.apache.org/job/PreCommit-HADOOP-Build/8754/console Powered by Apache Yetus 0.3.0-SNAPSHOT http://yetus.apache.org This message was automatically generated.
        Hide
        drankye Kai Zheng added a comment -

        Hi Andrew Wang, please let me know if I'd better test it locally. Thanks.

        Show
        drankye Kai Zheng added a comment - Hi Andrew Wang , please let me know if I'd better test it locally. Thanks.
        Hide
        andrew.wang Andrew Wang added a comment -

        LGTM, though could you do a manual test? I ran before and after, but didn't see any difference in the # of "hides a field" errors in the checkstyle output for HDFS.

        Show
        andrew.wang Andrew Wang added a comment - LGTM, though could you do a manual test? I ran before and after, but didn't see any difference in the # of "hides a field" errors in the checkstyle output for HDFS.
        Hide
        drankye Kai Zheng added a comment -

        Thanks Andrew for the review. Sure I will do a manual test locally.

        Show
        drankye Kai Zheng added a comment - Thanks Andrew for the review. Sure I will do a manual test locally.
        Hide
        drankye Kai Zheng added a comment -

        Hi Andrew, below is my trying.

        1. Given the current codes:

        [root@zkdesk hadoop]# mvn checkstyle:checkstyle
        [root@zkdesk hadoop]# grep -c 'hides a field' hadoop-common-project/hadoop-common/target/test/checkstyle-errors.xml 
        396
        

        2. Added the following test codes to the codebase in the hadoop-common module:

        +public class MyCheckstyleCheck {
        +  private String test1;
        +  private String test2;
        +  private String test3;
        +  private String test4;
        +
        +  public String getTest1() {
        +    return test1;
        +  }
        +
        +  public void setTest1(String test1) {
        +    this.test1 = test1;
        +  }
        +
        +  public String getTest2() {
        +    return test2;
        +  }
        +
        +  public void setTest2(String test2) {
        +    this.test2 = test2;
        +  }
        +
        +  public String getTest3() {
        +    return test3;
        +  }
        +
        +  public void setTest3(String test3) {
        +    this.test3 = test3;
        +  }
        +
        +  public String getTest4() {
        +    return test4;
        +  }
        +
        +  public void setTest4(String test4) {
        +    this.test4 = test4;
        +  }
        +}
        

        And run the above command again, it gives:

        [root@zkdesk hadoop]# grep -c 'hides a field' hadoop-common-project/hadoop-common/target/test/checkstyle-errors.xml 
        400
        

        3. Applied the patch here and tested again, it gave:

        [root@zkdesk hadoop]# grep -c 'hides a field' hadoop-common-project/hadoop-common/target/test/checkstyle-errors.xml 
        297
        

        In addition to mvn install as you mentioned in HADOOP-12713, I also ran mvn clean package to ensure the patch to take effect.
        Note this change shall not get rid of any hides a field warnings because in other cases the checking does make sense.

        Show
        drankye Kai Zheng added a comment - Hi Andrew, below is my trying. 1. Given the current codes: [root@zkdesk hadoop]# mvn checkstyle:checkstyle [root@zkdesk hadoop]# grep -c 'hides a field' hadoop-common-project/hadoop-common/target/test/checkstyle-errors.xml 396 2. Added the following test codes to the codebase in the hadoop-common module: + public class MyCheckstyleCheck { + private String test1; + private String test2; + private String test3; + private String test4; + + public String getTest1() { + return test1; + } + + public void setTest1( String test1) { + this .test1 = test1; + } + + public String getTest2() { + return test2; + } + + public void setTest2( String test2) { + this .test2 = test2; + } + + public String getTest3() { + return test3; + } + + public void setTest3( String test3) { + this .test3 = test3; + } + + public String getTest4() { + return test4; + } + + public void setTest4( String test4) { + this .test4 = test4; + } +} And run the above command again, it gives: [root@zkdesk hadoop]# grep -c 'hides a field' hadoop-common-project/hadoop-common/target/test/checkstyle-errors.xml 400 3. Applied the patch here and tested again, it gave: [root@zkdesk hadoop]# grep -c 'hides a field' hadoop-common-project/hadoop-common/target/test/checkstyle-errors.xml 297 In addition to mvn install as you mentioned in HADOOP-12713 , I also ran mvn clean package to ensure the patch to take effect. Note this change shall not get rid of any hides a field warnings because in other cases the checking does make sense.
        Hide
        andrew.wang Andrew Wang added a comment -

        Sounds great, let's check it in!

        Show
        andrew.wang Andrew Wang added a comment - Sounds great, let's check it in!
        Hide
        andrew.wang Andrew Wang added a comment -

        Committed to trunk and branch-2, thanks for the contribution Kai!

        Show
        andrew.wang Andrew Wang added a comment - Committed to trunk and branch-2, thanks for the contribution Kai!
        Hide
        hudson Hudson added a comment -

        FAILURE: Integrated in Hadoop-trunk-Commit #9412 (See https://builds.apache.org/job/Hadoop-trunk-Commit/9412/)
        HADOOP-12859. Disable hiding field style checks in class setters. (wang: rev 480302b4ba932ff16b88081dac651f0a5c46c09b)

        • hadoop-build-tools/src/main/resources/checkstyle/checkstyle.xml
        • hadoop-common-project/hadoop-common/CHANGES.txt
        Show
        hudson Hudson added a comment - FAILURE: Integrated in Hadoop-trunk-Commit #9412 (See https://builds.apache.org/job/Hadoop-trunk-Commit/9412/ ) HADOOP-12859 . Disable hiding field style checks in class setters. (wang: rev 480302b4ba932ff16b88081dac651f0a5c46c09b) hadoop-build-tools/src/main/resources/checkstyle/checkstyle.xml hadoop-common-project/hadoop-common/CHANGES.txt
        Hide
        drankye Kai Zheng added a comment -

        Thanks Andrew for having this!

        Show
        drankye Kai Zheng added a comment - Thanks Andrew for having this!
        Hide
        cmccabe Colin P. McCabe added a comment -

        Thanks, Andrew Wang and Kai Zheng.

        Show
        cmccabe Colin P. McCabe added a comment - Thanks, Andrew Wang and Kai Zheng .
        Hide
        andrew.wang Andrew Wang added a comment -

        I additionally backported this to branch-2.8.

        Show
        andrew.wang Andrew Wang added a comment - I additionally backported this to branch-2.8.

          People

          • Assignee:
            drankye Kai Zheng
            Reporter:
            drankye Kai Zheng
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development