Hadoop Common
  1. Hadoop Common
  2. HADOOP-7208

equals() and hashCode() implementation need to change in StandardSocketFactory

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.23.0
    • Fix Version/s: 0.23.0
    • Component/s: None
    • Labels:
      None
    • Hadoop Flags:
      Reviewed

      Description

      In Hadoop IPC Client, we are using ClientCache which will maintain the HashMap to keep the Client references.
      private Map<SocketFactory, Client> clients =
      new HashMap<SocketFactory, Client>();

      Now let us say, we want use two standard factories with Hadoop. MyStandardSocketFactory (which extends StandardSocketFactory), and StandardSocketFactory. In this case, because of equals and hashcode implementation, MyStandardSocketFactory client can be overridden by StandardSocketFactoryClient

      1. HADOOP-7208-3.patch
        4 kB
        Uma Maheswara Rao G
      2. HADOOP-7208-2.patch
        4 kB
        Uma Maheswara Rao G
      3. HADOOP-7208.patch
        5 kB
        Uma Maheswara Rao G

        Activity

        Hide
        Konstantin Shvachko added a comment -

        Which implementations of equals and hashcode do you mean?

        Show
        Konstantin Shvachko added a comment - Which implementations of equals and hashcode do you mean?
        Hide
        Uma Maheswara Rao G added a comment -

        equals and hashcode implementation in the class org.apache.hadoop.net.StandardSocketFactory

        Show
        Uma Maheswara Rao G added a comment - equals and hashcode implementation in the class org.apache.hadoop.net.StandardSocketFactory
        Hide
        Uma Maheswara Rao G added a comment -

        Sorry for the delay in replying and patch preparation.

        We may need this change if we use our custom StandardSocketFactory

        In the equals method if we change the implementation like
        return obj.getClass().getName().equals(this.getClass().getName());

        It gives a findbug error.

        Is it fine ? is there any way to get approval for the same.

        Show
        Uma Maheswara Rao G added a comment - Sorry for the delay in replying and patch preparation. We may need this change if we use our custom StandardSocketFactory In the equals method if we change the implementation like return obj.getClass().getName().equals(this.getClass().getName()); It gives a findbug error. Is it fine ? is there any way to get approval for the same.
        Hide
        Steve Loughran added a comment -

        checking by classname is wrong because if you have >1 classloader you can have multiple classes with the name -even singleton classes.

        Better to use this.getClass().equals(that.getClass())

        For a real review you really need to attach the patch

        Show
        Steve Loughran added a comment - checking by classname is wrong because if you have >1 classloader you can have multiple classes with the name -even singleton classes. Better to use this.getClass().equals(that.getClass()) For a real review you really need to attach the patch
        Hide
        Hadoop QA added a comment -

        +1 overall. Here are the results of testing the latest attachment
        http://issues.apache.org/jira/secure/attachment/12480117/HADOOP-7208.patch
        against trunk revision 1126287.

        +1 @author. The patch does not contain any @author tags.

        +1 tests included. The patch appears to include 3 new or modified tests.

        +1 javadoc. The javadoc tool did not generate any warning messages.

        +1 javac. The applied patch does not increase the total number of javac compiler warnings.

        +1 findbugs. The patch does not introduce any new Findbugs (version 1.3.9) warnings.

        +1 release audit. The applied patch does not increase the total number of release audit warnings.

        +1 core tests. The patch passed core unit tests.

        +1 system test framework. The patch passed system test framework compile.

        Test results: https://builds.apache.org/hudson/job/PreCommit-HADOOP-Build/504//testReport/
        Findbugs warnings: https://builds.apache.org/hudson/job/PreCommit-HADOOP-Build/504//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
        Console output: https://builds.apache.org/hudson/job/PreCommit-HADOOP-Build/504//console

        This message is automatically generated.

        Show
        Hadoop QA added a comment - +1 overall. Here are the results of testing the latest attachment http://issues.apache.org/jira/secure/attachment/12480117/HADOOP-7208.patch against trunk revision 1126287. +1 @author. The patch does not contain any @author tags. +1 tests included. The patch appears to include 3 new or modified tests. +1 javadoc. The javadoc tool did not generate any warning messages. +1 javac. The applied patch does not increase the total number of javac compiler warnings. +1 findbugs. The patch does not introduce any new Findbugs (version 1.3.9) warnings. +1 release audit. The applied patch does not increase the total number of release audit warnings. +1 core tests. The patch passed core unit tests. +1 system test framework. The patch passed system test framework compile. Test results: https://builds.apache.org/hudson/job/PreCommit-HADOOP-Build/504//testReport/ Findbugs warnings: https://builds.apache.org/hudson/job/PreCommit-HADOOP-Build/504//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html Console output: https://builds.apache.org/hudson/job/PreCommit-HADOOP-Build/504//console This message is automatically generated.
        Hide
        Todd Lipcon added a comment -
        • please use spaces, not tabs for indentation
        • should probably remove the comment "dummy hash code"
        • in tests, please use assertEquals instead of assertTrue with an == condition. Same for the false assertion
        • to illustrate the bug, does DummySocketFactory need to override anything at all? I think it could just be an empty subclass. Also, the attached javadoc doesn't represent what it does
        Show
        Todd Lipcon added a comment - please use spaces, not tabs for indentation should probably remove the comment "dummy hash code" in tests, please use assertEquals instead of assertTrue with an == condition. Same for the false assertion to illustrate the bug, does DummySocketFactory need to override anything at all? I think it could just be an empty subclass. Also, the attached javadoc doesn't represent what it does
        Hide
        Hadoop QA added a comment -

        +1 overall. Here are the results of testing the latest attachment
        http://issues.apache.org/jira/secure/attachment/12480249/HADOOP-7208-2.patch
        against trunk revision 1126719.

        +1 @author. The patch does not contain any @author tags.

        +1 tests included. The patch appears to include 3 new or modified tests.

        +1 javadoc. The javadoc tool did not generate any warning messages.

        +1 javac. The applied patch does not increase the total number of javac compiler warnings.

        +1 findbugs. The patch does not introduce any new Findbugs (version 1.3.9) warnings.

        +1 release audit. The applied patch does not increase the total number of release audit warnings.

        +1 core tests. The patch passed core unit tests.

        +1 system test framework. The patch passed system test framework compile.

        Test results: https://builds.apache.org/hudson/job/PreCommit-HADOOP-Build/514//testReport/
        Findbugs warnings: https://builds.apache.org/hudson/job/PreCommit-HADOOP-Build/514//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
        Console output: https://builds.apache.org/hudson/job/PreCommit-HADOOP-Build/514//console

        This message is automatically generated.

        Show
        Hadoop QA added a comment - +1 overall. Here are the results of testing the latest attachment http://issues.apache.org/jira/secure/attachment/12480249/HADOOP-7208-2.patch against trunk revision 1126719. +1 @author. The patch does not contain any @author tags. +1 tests included. The patch appears to include 3 new or modified tests. +1 javadoc. The javadoc tool did not generate any warning messages. +1 javac. The applied patch does not increase the total number of javac compiler warnings. +1 findbugs. The patch does not introduce any new Findbugs (version 1.3.9) warnings. +1 release audit. The applied patch does not increase the total number of release audit warnings. +1 core tests. The patch passed core unit tests. +1 system test framework. The patch passed system test framework compile. Test results: https://builds.apache.org/hudson/job/PreCommit-HADOOP-Build/514//testReport/ Findbugs warnings: https://builds.apache.org/hudson/job/PreCommit-HADOOP-Build/514//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html Console output: https://builds.apache.org/hudson/job/PreCommit-HADOOP-Build/514//console This message is automatically generated.
        Hide
        Todd Lipcon added a comment -
        • There are still hard tabs in this patch.
        • there is no contract that hashCode() has to differ if two objects are unequal – so your unit test there is not valid
        • for the implementation of hashcode, might as well use getClass().hashCode() – you don't need to get the class name
        Show
        Todd Lipcon added a comment - There are still hard tabs in this patch. there is no contract that hashCode() has to differ if two objects are unequal – so your unit test there is not valid for the implementation of hashcode, might as well use getClass().hashCode() – you don't need to get the class name
        Hide
        Hadoop QA added a comment -

        +1 overall. Here are the results of testing the latest attachment
        http://issues.apache.org/jira/secure/attachment/12480944/HADOOP-7208-3.patch
        against trunk revision 1128789.

        +1 @author. The patch does not contain any @author tags.

        +1 tests included. The patch appears to include 3 new or modified tests.

        +1 javadoc. The javadoc tool did not generate any warning messages.

        +1 javac. The applied patch does not increase the total number of javac compiler warnings.

        +1 findbugs. The patch does not introduce any new Findbugs (version 1.3.9) warnings.

        +1 release audit. The applied patch does not increase the total number of release audit warnings.

        +1 core tests. The patch passed core unit tests.

        +1 system test framework. The patch passed system test framework compile.

        Test results: https://builds.apache.org/hudson/job/PreCommit-HADOOP-Build/545//testReport/
        Findbugs warnings: https://builds.apache.org/hudson/job/PreCommit-HADOOP-Build/545//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
        Console output: https://builds.apache.org/hudson/job/PreCommit-HADOOP-Build/545//console

        This message is automatically generated.

        Show
        Hadoop QA added a comment - +1 overall. Here are the results of testing the latest attachment http://issues.apache.org/jira/secure/attachment/12480944/HADOOP-7208-3.patch against trunk revision 1128789. +1 @author. The patch does not contain any @author tags. +1 tests included. The patch appears to include 3 new or modified tests. +1 javadoc. The javadoc tool did not generate any warning messages. +1 javac. The applied patch does not increase the total number of javac compiler warnings. +1 findbugs. The patch does not introduce any new Findbugs (version 1.3.9) warnings. +1 release audit. The applied patch does not increase the total number of release audit warnings. +1 core tests. The patch passed core unit tests. +1 system test framework. The patch passed system test framework compile. Test results: https://builds.apache.org/hudson/job/PreCommit-HADOOP-Build/545//testReport/ Findbugs warnings: https://builds.apache.org/hudson/job/PreCommit-HADOOP-Build/545//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html Console output: https://builds.apache.org/hudson/job/PreCommit-HADOOP-Build/545//console This message is automatically generated.
        Hide
        Todd Lipcon added a comment -

        +1. Committed to trunk. Thanks, Uma

        Show
        Todd Lipcon added a comment - +1. Committed to trunk. Thanks, Uma
        Hide
        Hudson added a comment -

        Integrated in Hadoop-Common-trunk-Commit #629 (See https://builds.apache.org/hudson/job/Hadoop-Common-trunk-Commit/629/)
        HADOOP-7208. Fix implementation of equals() and hashCode() in StandardSocketFactory. Contributed by Uma Maheswara Rao G.

        todd : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1129840
        Files :

        • /hadoop/common/trunk/CHANGES.txt
        • /hadoop/common/trunk/src/test/core/org/apache/hadoop/ipc/TestSocketFactory.java
        • /hadoop/common/trunk/src/java/org/apache/hadoop/net/StandardSocketFactory.java
        Show
        Hudson added a comment - Integrated in Hadoop-Common-trunk-Commit #629 (See https://builds.apache.org/hudson/job/Hadoop-Common-trunk-Commit/629/ ) HADOOP-7208 . Fix implementation of equals() and hashCode() in StandardSocketFactory. Contributed by Uma Maheswara Rao G. todd : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1129840 Files : /hadoop/common/trunk/CHANGES.txt /hadoop/common/trunk/src/test/core/org/apache/hadoop/ipc/TestSocketFactory.java /hadoop/common/trunk/src/java/org/apache/hadoop/net/StandardSocketFactory.java
        Hide
        Hudson added a comment -

        Integrated in Hadoop-Common-trunk #706 (See https://builds.apache.org/hudson/job/Hadoop-Common-trunk/706/)
        HADOOP-7208. Fix implementation of equals() and hashCode() in StandardSocketFactory. Contributed by Uma Maheswara Rao G.

        todd : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1129840
        Files :

        • /hadoop/common/trunk/CHANGES.txt
        • /hadoop/common/trunk/src/test/core/org/apache/hadoop/ipc/TestSocketFactory.java
        • /hadoop/common/trunk/src/java/org/apache/hadoop/net/StandardSocketFactory.java
        Show
        Hudson added a comment - Integrated in Hadoop-Common-trunk #706 (See https://builds.apache.org/hudson/job/Hadoop-Common-trunk/706/ ) HADOOP-7208 . Fix implementation of equals() and hashCode() in StandardSocketFactory. Contributed by Uma Maheswara Rao G. todd : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1129840 Files : /hadoop/common/trunk/CHANGES.txt /hadoop/common/trunk/src/test/core/org/apache/hadoop/ipc/TestSocketFactory.java /hadoop/common/trunk/src/java/org/apache/hadoop/net/StandardSocketFactory.java

          People

          • Assignee:
            Uma Maheswara Rao G
            Reporter:
            Uma Maheswara Rao G
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development