You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-dev@hadoop.apache.org by "Suresh Srinivas (JIRA)" <ji...@apache.org> on 2008/09/19 03:16:44 UTC

[jira] Created: (HADOOP-4210) Findbugs warnings are printed related to equals implementation of several classes

Findbugs warnings are printed related to equals implementation of several classes
---------------------------------------------------------------------------------

                 Key: HADOOP-4210
                 URL: https://issues.apache.org/jira/browse/HADOOP-4210
             Project: Hadoop Core
          Issue Type: Bug
            Reporter: Suresh Srinivas
            Assignee: Suresh Srinivas
             Fix For: 0.19.0


During compilation - findbugs generates several warnings that indicates bugs in the implementation of equals method. One of the example of this report is:

Bug type EQ_GETCLASS_AND_CLASS_CONSTANT (click for details)
In class org.apache.hadoop.mapred.ID
In method org.apache.hadoop.mapred.ID.equals(Object)
At ID.java:[line 66]
Value doesn't work for subtypes

This class has an equals method that will be broken if it is inherited by subclasses. It compares a class literal with the class of the argument (e.g., in class Foo it might check if Foo.class == o.getClass()). It is better to check if this.getClass() == o.getClass().




-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HADOOP-4210) Findbugs warnings are printed related to equals implementation of several classes

Posted by "Robert Chansler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-4210?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Robert Chansler updated HADOOP-4210:
------------------------------------

    Release Note: 
Changed public class org.apache.hadoop.mapreduce.ID to be an abstract class. Removed from class org.apache.hadoop.mapreduce.ID the methods  public static ID read(DataInput in) and public static ID forName(String str).


  was:
The incompatible changes includes:
Following are the incompatible changes:
- public class org.apache.hadoop.mapreduce.ID is changed to an abstract class
- Following methods from the class org.apache.hadoop.mapreduce.ID is removed:
  public static ID read(DataInput in) 
  public static ID forName(String str) 


    Hadoop Flags: [Incompatible change, Reviewed]  (was: [Reviewed, Incompatible change])

Edit release note for publication.

> Findbugs warnings are printed related to equals implementation of several classes
> ---------------------------------------------------------------------------------
>
>                 Key: HADOOP-4210
>                 URL: https://issues.apache.org/jira/browse/HADOOP-4210
>             Project: Hadoop Core
>          Issue Type: Bug
>          Components: mapred
>            Reporter: Suresh Srinivas
>            Assignee: Suresh Srinivas
>             Fix For: 0.20.0
>
>         Attachments: HADOOP-4210.patch, HADOOP-4210.patch, HADOOP4210.patch
>
>
> During compilation - findbugs generates several warnings that indicates bugs in the implementation of equals method. One of the example of this report is:
> Bug type EQ_GETCLASS_AND_CLASS_CONSTANT (click for details)
> In class org.apache.hadoop.mapred.ID
> In method org.apache.hadoop.mapred.ID.equals(Object)
> At ID.java:[line 66]
> Value doesn't work for subtypes
> This class has an equals method that will be broken if it is inherited by subclasses. It compares a class literal with the class of the argument (e.g., in class Foo it might check if Foo.class == o.getClass()). It is better to check if this.getClass() == o.getClass().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HADOOP-4210) Findbugs warnings are printed related to equals implementation of several classes

Posted by "Suresh Srinivas (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-4210?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Suresh Srinivas updated HADOOP-4210:
------------------------------------

    Attachment: HADOOP-4210.patch

Updated patch

> Findbugs warnings are printed related to equals implementation of several classes
> ---------------------------------------------------------------------------------
>
>                 Key: HADOOP-4210
>                 URL: https://issues.apache.org/jira/browse/HADOOP-4210
>             Project: Hadoop Core
>          Issue Type: Bug
>            Reporter: Suresh Srinivas
>            Assignee: Suresh Srinivas
>             Fix For: 0.19.0
>
>         Attachments: HADOOP-4210.patch, HADOOP-4210.patch, HADOOP4210.patch
>
>
> During compilation - findbugs generates several warnings that indicates bugs in the implementation of equals method. One of the example of this report is:
> Bug type EQ_GETCLASS_AND_CLASS_CONSTANT (click for details)
> In class org.apache.hadoop.mapred.ID
> In method org.apache.hadoop.mapred.ID.equals(Object)
> At ID.java:[line 66]
> Value doesn't work for subtypes
> This class has an equals method that will be broken if it is inherited by subclasses. It compares a class literal with the class of the argument (e.g., in class Foo it might check if Foo.class == o.getClass()). It is better to check if this.getClass() == o.getClass().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HADOOP-4210) Findbugs warnings are printed related to equals implementation of several classes

Posted by "Suresh Srinivas (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-4210?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Suresh Srinivas updated HADOOP-4210:
------------------------------------

    Status: Open  (was: Patch Available)

> Findbugs warnings are printed related to equals implementation of several classes
> ---------------------------------------------------------------------------------
>
>                 Key: HADOOP-4210
>                 URL: https://issues.apache.org/jira/browse/HADOOP-4210
>             Project: Hadoop Core
>          Issue Type: Bug
>            Reporter: Suresh Srinivas
>            Assignee: Suresh Srinivas
>             Fix For: 0.20.0
>
>         Attachments: HADOOP-4210.patch, HADOOP-4210.patch, HADOOP4210.patch
>
>
> During compilation - findbugs generates several warnings that indicates bugs in the implementation of equals method. One of the example of this report is:
> Bug type EQ_GETCLASS_AND_CLASS_CONSTANT (click for details)
> In class org.apache.hadoop.mapred.ID
> In method org.apache.hadoop.mapred.ID.equals(Object)
> At ID.java:[line 66]
> Value doesn't work for subtypes
> This class has an equals method that will be broken if it is inherited by subclasses. It compares a class literal with the class of the argument (e.g., in class Foo it might check if Foo.class == o.getClass()). It is better to check if this.getClass() == o.getClass().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HADOOP-4210) Findbugs warnings are printed related to equals implementation of several classes

Posted by "Suresh Srinivas (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-4210?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12635782#action_12635782 ] 

Suresh Srinivas commented on HADOOP-4210:
-----------------------------------------

HDFS test TestLeaseRecovery2 is failing. It is unrelated to this change (it is failing for other patches too)

> Findbugs warnings are printed related to equals implementation of several classes
> ---------------------------------------------------------------------------------
>
>                 Key: HADOOP-4210
>                 URL: https://issues.apache.org/jira/browse/HADOOP-4210
>             Project: Hadoop Core
>          Issue Type: Bug
>            Reporter: Suresh Srinivas
>            Assignee: Suresh Srinivas
>             Fix For: 0.20.0
>
>         Attachments: HADOOP-4210.patch, HADOOP-4210.patch, HADOOP4210.patch
>
>
> During compilation - findbugs generates several warnings that indicates bugs in the implementation of equals method. One of the example of this report is:
> Bug type EQ_GETCLASS_AND_CLASS_CONSTANT (click for details)
> In class org.apache.hadoop.mapred.ID
> In method org.apache.hadoop.mapred.ID.equals(Object)
> At ID.java:[line 66]
> Value doesn't work for subtypes
> This class has an equals method that will be broken if it is inherited by subclasses. It compares a class literal with the class of the argument (e.g., in class Foo it might check if Foo.class == o.getClass()). It is better to check if this.getClass() == o.getClass().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HADOOP-4210) Findbugs warnings are printed related to equals implementation of several classes

Posted by "Suresh Srinivas (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-4210?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Suresh Srinivas updated HADOOP-4210:
------------------------------------

    Attachment: HADOOP-4210.patch

Incorporating code review comments from Chris:
1. Use base class equals method in the sub classes
2. Class ID should not be instantiated. Hence making it abstract and removing the unused static methods that were instantiating the class ID.

> Findbugs warnings are printed related to equals implementation of several classes
> ---------------------------------------------------------------------------------
>
>                 Key: HADOOP-4210
>                 URL: https://issues.apache.org/jira/browse/HADOOP-4210
>             Project: Hadoop Core
>          Issue Type: Bug
>            Reporter: Suresh Srinivas
>            Assignee: Suresh Srinivas
>             Fix For: 0.19.0
>
>         Attachments: HADOOP-4210.patch, HADOOP4210.patch
>
>
> During compilation - findbugs generates several warnings that indicates bugs in the implementation of equals method. One of the example of this report is:
> Bug type EQ_GETCLASS_AND_CLASS_CONSTANT (click for details)
> In class org.apache.hadoop.mapred.ID
> In method org.apache.hadoop.mapred.ID.equals(Object)
> At ID.java:[line 66]
> Value doesn't work for subtypes
> This class has an equals method that will be broken if it is inherited by subclasses. It compares a class literal with the class of the argument (e.g., in class Foo it might check if Foo.class == o.getClass()). It is better to check if this.getClass() == o.getClass().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HADOOP-4210) Findbugs warnings are printed related to equals implementation of several classes

Posted by "Suresh Srinivas (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-4210?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Suresh Srinivas updated HADOOP-4210:
------------------------------------

    Attachment: HADOOP4210.patch

Fixing the issue reported by changing the implementation of equals to be consistent at all the places where bugs were reported. The implementation of equals ensures the following checks are consistently done before the internal data comparison of the two objects:
- Returns true if the object references are equal
- Returns false if the object passed as parameter is null
- Returns false if the this.getClass() != paramObject.getClass()




> Findbugs warnings are printed related to equals implementation of several classes
> ---------------------------------------------------------------------------------
>
>                 Key: HADOOP-4210
>                 URL: https://issues.apache.org/jira/browse/HADOOP-4210
>             Project: Hadoop Core
>          Issue Type: Bug
>            Reporter: Suresh Srinivas
>            Assignee: Suresh Srinivas
>             Fix For: 0.19.0
>
>         Attachments: HADOOP4210.patch
>
>
> During compilation - findbugs generates several warnings that indicates bugs in the implementation of equals method. One of the example of this report is:
> Bug type EQ_GETCLASS_AND_CLASS_CONSTANT (click for details)
> In class org.apache.hadoop.mapred.ID
> In method org.apache.hadoop.mapred.ID.equals(Object)
> At ID.java:[line 66]
> Value doesn't work for subtypes
> This class has an equals method that will be broken if it is inherited by subclasses. It compares a class literal with the class of the argument (e.g., in class Foo it might check if Foo.class == o.getClass()). It is better to check if this.getClass() == o.getClass().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HADOOP-4210) Findbugs warnings are printed related to equals implementation of several classes

Posted by "Robert Chansler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-4210?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Robert Chansler updated HADOOP-4210:
------------------------------------

    Release Note: Changed public class org.apache.hadoop.mapreduce.ID to be an abstract class. Removed from class org.apache.hadoop.mapreduce.ID the methods  public static ID read(DataInput in) and public static ID forName(String str).  (was: Changed public class org.apache.hadoop.mapreduce.ID to be an abstract class. Removed from class org.apache.hadoop.mapreduce.ID the methods  public static ID read(DataInput in) and public static ID forName(String str).
)
    Hadoop Flags: [Incompatible change, Reviewed]  (was: [Reviewed, Incompatible change])

> Findbugs warnings are printed related to equals implementation of several classes
> ---------------------------------------------------------------------------------
>
>                 Key: HADOOP-4210
>                 URL: https://issues.apache.org/jira/browse/HADOOP-4210
>             Project: Hadoop Core
>          Issue Type: Bug
>          Components: mapred
>            Reporter: Suresh Srinivas
>            Assignee: Suresh Srinivas
>             Fix For: 0.20.0
>
>         Attachments: HADOOP-4210.patch, HADOOP-4210.patch, HADOOP4210.patch
>
>
> During compilation - findbugs generates several warnings that indicates bugs in the implementation of equals method. One of the example of this report is:
> Bug type EQ_GETCLASS_AND_CLASS_CONSTANT (click for details)
> In class org.apache.hadoop.mapred.ID
> In method org.apache.hadoop.mapred.ID.equals(Object)
> At ID.java:[line 66]
> Value doesn't work for subtypes
> This class has an equals method that will be broken if it is inherited by subclasses. It compares a class literal with the class of the argument (e.g., in class Foo it might check if Foo.class == o.getClass()). It is better to check if this.getClass() == o.getClass().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HADOOP-4210) Findbugs warnings are printed related to equals implementation of several classes

Posted by "Chris Douglas (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-4210?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chris Douglas updated HADOOP-4210:
----------------------------------

     Component/s: mapred
    Hadoop Flags: [Incompatible change, Reviewed]  (was: [Reviewed, Incompatible change])

> Findbugs warnings are printed related to equals implementation of several classes
> ---------------------------------------------------------------------------------
>
>                 Key: HADOOP-4210
>                 URL: https://issues.apache.org/jira/browse/HADOOP-4210
>             Project: Hadoop Core
>          Issue Type: Bug
>          Components: mapred
>            Reporter: Suresh Srinivas
>            Assignee: Suresh Srinivas
>             Fix For: 0.20.0
>
>         Attachments: HADOOP-4210.patch, HADOOP-4210.patch, HADOOP4210.patch
>
>
> During compilation - findbugs generates several warnings that indicates bugs in the implementation of equals method. One of the example of this report is:
> Bug type EQ_GETCLASS_AND_CLASS_CONSTANT (click for details)
> In class org.apache.hadoop.mapred.ID
> In method org.apache.hadoop.mapred.ID.equals(Object)
> At ID.java:[line 66]
> Value doesn't work for subtypes
> This class has an equals method that will be broken if it is inherited by subclasses. It compares a class literal with the class of the argument (e.g., in class Foo it might check if Foo.class == o.getClass()). It is better to check if this.getClass() == o.getClass().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HADOOP-4210) Findbugs warnings are printed related to equals implementation of several classes

Posted by "Hadoop QA (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-4210?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12635737#action_12635737 ] 

Hadoop QA commented on HADOOP-4210:
-----------------------------------

-1 overall.  Here are the results of testing the latest attachment 
  http://issues.apache.org/jira/secure/attachment/12390452/HADOOP-4210.patch
  against trunk revision 700322.

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

    -1 tests included.  The patch doesn't appear to include any new or modified tests.
                        Please justify why no tests are needed for this patch.

    +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 warnings.

    +1 Eclipse classpath. The patch retains Eclipse classpath integrity.

    -1 core tests.  The patch failed core unit tests.

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

Test results: http://hudson.zones.apache.org/hudson/job/Hadoop-Patch/3402/testReport/
Findbugs warnings: http://hudson.zones.apache.org/hudson/job/Hadoop-Patch/3402/artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
Checkstyle results: http://hudson.zones.apache.org/hudson/job/Hadoop-Patch/3402/artifact/trunk/build/test/checkstyle-errors.html
Console output: http://hudson.zones.apache.org/hudson/job/Hadoop-Patch/3402/console

This message is automatically generated.

> Findbugs warnings are printed related to equals implementation of several classes
> ---------------------------------------------------------------------------------
>
>                 Key: HADOOP-4210
>                 URL: https://issues.apache.org/jira/browse/HADOOP-4210
>             Project: Hadoop Core
>          Issue Type: Bug
>            Reporter: Suresh Srinivas
>            Assignee: Suresh Srinivas
>             Fix For: 0.20.0
>
>         Attachments: HADOOP-4210.patch, HADOOP-4210.patch, HADOOP4210.patch
>
>
> During compilation - findbugs generates several warnings that indicates bugs in the implementation of equals method. One of the example of this report is:
> Bug type EQ_GETCLASS_AND_CLASS_CONSTANT (click for details)
> In class org.apache.hadoop.mapred.ID
> In method org.apache.hadoop.mapred.ID.equals(Object)
> At ID.java:[line 66]
> Value doesn't work for subtypes
> This class has an equals method that will be broken if it is inherited by subclasses. It compares a class literal with the class of the argument (e.g., in class Foo it might check if Foo.class == o.getClass()). It is better to check if this.getClass() == o.getClass().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HADOOP-4210) Findbugs warnings are printed related to equals implementation of several classes

Posted by "Suresh Srinivas (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-4210?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Suresh Srinivas updated HADOOP-4210:
------------------------------------

    Hadoop Flags: [Incompatible change, Reviewed]  (was: [Reviewed, Incompatible change])
          Status: Patch Available  (was: Open)

> Findbugs warnings are printed related to equals implementation of several classes
> ---------------------------------------------------------------------------------
>
>                 Key: HADOOP-4210
>                 URL: https://issues.apache.org/jira/browse/HADOOP-4210
>             Project: Hadoop Core
>          Issue Type: Bug
>            Reporter: Suresh Srinivas
>            Assignee: Suresh Srinivas
>             Fix For: 0.20.0
>
>         Attachments: HADOOP-4210.patch, HADOOP-4210.patch, HADOOP4210.patch
>
>
> During compilation - findbugs generates several warnings that indicates bugs in the implementation of equals method. One of the example of this report is:
> Bug type EQ_GETCLASS_AND_CLASS_CONSTANT (click for details)
> In class org.apache.hadoop.mapred.ID
> In method org.apache.hadoop.mapred.ID.equals(Object)
> At ID.java:[line 66]
> Value doesn't work for subtypes
> This class has an equals method that will be broken if it is inherited by subclasses. It compares a class literal with the class of the argument (e.g., in class Foo it might check if Foo.class == o.getClass()). It is better to check if this.getClass() == o.getClass().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HADOOP-4210) Findbugs warnings are printed related to equals implementation of several classes

Posted by "Suresh Srinivas (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-4210?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Suresh Srinivas updated HADOOP-4210:
------------------------------------

    Release Note: 
The incompatible changes includes:
Following are the incompatible changes:
- public class org.apache.hadoop.mapreduce.ID is changed to an abstract class
- Following methods from the class org.apache.hadoop.mapreduce.ID is removed:
  public static ID read(DataInput in) 
  public static ID forName(String str) 

          Status: Patch Available  (was: Open)

> Findbugs warnings are printed related to equals implementation of several classes
> ---------------------------------------------------------------------------------
>
>                 Key: HADOOP-4210
>                 URL: https://issues.apache.org/jira/browse/HADOOP-4210
>             Project: Hadoop Core
>          Issue Type: Bug
>            Reporter: Suresh Srinivas
>            Assignee: Suresh Srinivas
>             Fix For: 0.20.0
>
>         Attachments: HADOOP-4210.patch, HADOOP-4210.patch, HADOOP4210.patch
>
>
> During compilation - findbugs generates several warnings that indicates bugs in the implementation of equals method. One of the example of this report is:
> Bug type EQ_GETCLASS_AND_CLASS_CONSTANT (click for details)
> In class org.apache.hadoop.mapred.ID
> In method org.apache.hadoop.mapred.ID.equals(Object)
> At ID.java:[line 66]
> Value doesn't work for subtypes
> This class has an equals method that will be broken if it is inherited by subclasses. It compares a class literal with the class of the argument (e.g., in class Foo it might check if Foo.class == o.getClass()). It is better to check if this.getClass() == o.getClass().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HADOOP-4210) Findbugs warnings are printed related to equals implementation of several classes

Posted by "Chris Douglas (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-4210?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chris Douglas updated HADOOP-4210:
----------------------------------

    Fix Version/s:     (was: 0.19.0)
                   0.20.0
     Hadoop Flags: [Incompatible change]

Changed fix version to 0.20 (HADOOP-1230, i.e. the o.a.h.mapreduce package, is no longer in the 0.19 branch. If this qualifies as a bug fix, the patch for 0.19 should be regenerated). Also marking this as an incompatible change, as it removes public methods (that shouldn't be- and in core, are not- used) from ID. Do ID and its subclasses need to be a public classes? All can probably be package-private.

> Findbugs warnings are printed related to equals implementation of several classes
> ---------------------------------------------------------------------------------
>
>                 Key: HADOOP-4210
>                 URL: https://issues.apache.org/jira/browse/HADOOP-4210
>             Project: Hadoop Core
>          Issue Type: Bug
>            Reporter: Suresh Srinivas
>            Assignee: Suresh Srinivas
>             Fix For: 0.20.0
>
>         Attachments: HADOOP-4210.patch, HADOOP-4210.patch, HADOOP4210.patch
>
>
> During compilation - findbugs generates several warnings that indicates bugs in the implementation of equals method. One of the example of this report is:
> Bug type EQ_GETCLASS_AND_CLASS_CONSTANT (click for details)
> In class org.apache.hadoop.mapred.ID
> In method org.apache.hadoop.mapred.ID.equals(Object)
> At ID.java:[line 66]
> Value doesn't work for subtypes
> This class has an equals method that will be broken if it is inherited by subclasses. It compares a class literal with the class of the argument (e.g., in class Foo it might check if Foo.class == o.getClass()). It is better to check if this.getClass() == o.getClass().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HADOOP-4210) Findbugs warnings are printed related to equals implementation of several classes

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-4210?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12636026#action_12636026 ] 

Hudson commented on HADOOP-4210:
--------------------------------

Integrated in Hadoop-trunk #620 (See [http://hudson.zones.apache.org/hudson/job/Hadoop-trunk/620/])
    . Fix findbugs warnings for equals implementations of mapred ID
classes. Removed public, static ID::read and ID::forName; made ID an
abstract class. Contributed by Suresh Srinivas.


> Findbugs warnings are printed related to equals implementation of several classes
> ---------------------------------------------------------------------------------
>
>                 Key: HADOOP-4210
>                 URL: https://issues.apache.org/jira/browse/HADOOP-4210
>             Project: Hadoop Core
>          Issue Type: Bug
>          Components: mapred
>            Reporter: Suresh Srinivas
>            Assignee: Suresh Srinivas
>             Fix For: 0.20.0
>
>         Attachments: HADOOP-4210.patch, HADOOP-4210.patch, HADOOP4210.patch
>
>
> During compilation - findbugs generates several warnings that indicates bugs in the implementation of equals method. One of the example of this report is:
> Bug type EQ_GETCLASS_AND_CLASS_CONSTANT (click for details)
> In class org.apache.hadoop.mapred.ID
> In method org.apache.hadoop.mapred.ID.equals(Object)
> At ID.java:[line 66]
> Value doesn't work for subtypes
> This class has an equals method that will be broken if it is inherited by subclasses. It compares a class literal with the class of the argument (e.g., in class Foo it might check if Foo.class == o.getClass()). It is better to check if this.getClass() == o.getClass().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HADOOP-4210) Findbugs warnings are printed related to equals implementation of several classes

Posted by "Tsz Wo (Nicholas), SZE (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-4210?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12634310#action_12634310 ] 

Tsz Wo (Nicholas), SZE commented on HADOOP-4210:
------------------------------------------------

> Returns false if the this.getClass() != paramObject.getClass()

For class comparison, should we use equals(...) instead of ==?  Otherwise, I am afraid it won't work in dynamic class loading.

> Findbugs warnings are printed related to equals implementation of several classes
> ---------------------------------------------------------------------------------
>
>                 Key: HADOOP-4210
>                 URL: https://issues.apache.org/jira/browse/HADOOP-4210
>             Project: Hadoop Core
>          Issue Type: Bug
>            Reporter: Suresh Srinivas
>            Assignee: Suresh Srinivas
>             Fix For: 0.20.0
>
>         Attachments: HADOOP-4210.patch, HADOOP-4210.patch, HADOOP4210.patch
>
>
> During compilation - findbugs generates several warnings that indicates bugs in the implementation of equals method. One of the example of this report is:
> Bug type EQ_GETCLASS_AND_CLASS_CONSTANT (click for details)
> In class org.apache.hadoop.mapred.ID
> In method org.apache.hadoop.mapred.ID.equals(Object)
> At ID.java:[line 66]
> Value doesn't work for subtypes
> This class has an equals method that will be broken if it is inherited by subclasses. It compares a class literal with the class of the argument (e.g., in class Foo it might check if Foo.class == o.getClass()). It is better to check if this.getClass() == o.getClass().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HADOOP-4210) Findbugs warnings are printed related to equals implementation of several classes

Posted by "Suresh Srinivas (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-4210?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Suresh Srinivas updated HADOOP-4210:
------------------------------------

    Status: Patch Available  (was: Open)

After this change, the number of "Correctness Warnings" printed by find bugs reduced from 18 to 8. There is no automated test case written for this change.

> Findbugs warnings are printed related to equals implementation of several classes
> ---------------------------------------------------------------------------------
>
>                 Key: HADOOP-4210
>                 URL: https://issues.apache.org/jira/browse/HADOOP-4210
>             Project: Hadoop Core
>          Issue Type: Bug
>            Reporter: Suresh Srinivas
>            Assignee: Suresh Srinivas
>             Fix For: 0.19.0
>
>         Attachments: HADOOP4210.patch
>
>
> During compilation - findbugs generates several warnings that indicates bugs in the implementation of equals method. One of the example of this report is:
> Bug type EQ_GETCLASS_AND_CLASS_CONSTANT (click for details)
> In class org.apache.hadoop.mapred.ID
> In method org.apache.hadoop.mapred.ID.equals(Object)
> At ID.java:[line 66]
> Value doesn't work for subtypes
> This class has an equals method that will be broken if it is inherited by subclasses. It compares a class literal with the class of the argument (e.g., in class Foo it might check if Foo.class == o.getClass()). It is better to check if this.getClass() == o.getClass().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HADOOP-4210) Findbugs warnings are printed related to equals implementation of several classes

Posted by "Chris Douglas (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-4210?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chris Douglas updated HADOOP-4210:
----------------------------------

      Resolution: Fixed
    Hadoop Flags: [Incompatible change, Reviewed]  (was: [Reviewed, Incompatible change])
          Status: Resolved  (was: Patch Available)

I just committed this. Thanks, Suresh

> Findbugs warnings are printed related to equals implementation of several classes
> ---------------------------------------------------------------------------------
>
>                 Key: HADOOP-4210
>                 URL: https://issues.apache.org/jira/browse/HADOOP-4210
>             Project: Hadoop Core
>          Issue Type: Bug
>          Components: mapred
>            Reporter: Suresh Srinivas
>            Assignee: Suresh Srinivas
>             Fix For: 0.20.0
>
>         Attachments: HADOOP-4210.patch, HADOOP-4210.patch, HADOOP4210.patch
>
>
> During compilation - findbugs generates several warnings that indicates bugs in the implementation of equals method. One of the example of this report is:
> Bug type EQ_GETCLASS_AND_CLASS_CONSTANT (click for details)
> In class org.apache.hadoop.mapred.ID
> In method org.apache.hadoop.mapred.ID.equals(Object)
> At ID.java:[line 66]
> Value doesn't work for subtypes
> This class has an equals method that will be broken if it is inherited by subclasses. It compares a class literal with the class of the argument (e.g., in class Foo it might check if Foo.class == o.getClass()). It is better to check if this.getClass() == o.getClass().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HADOOP-4210) Findbugs warnings are printed related to equals implementation of several classes

Posted by "Suresh Srinivas (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-4210?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Suresh Srinivas updated HADOOP-4210:
------------------------------------

    Status: Open  (was: Patch Available)

> Findbugs warnings are printed related to equals implementation of several classes
> ---------------------------------------------------------------------------------
>
>                 Key: HADOOP-4210
>                 URL: https://issues.apache.org/jira/browse/HADOOP-4210
>             Project: Hadoop Core
>          Issue Type: Bug
>            Reporter: Suresh Srinivas
>            Assignee: Suresh Srinivas
>             Fix For: 0.20.0
>
>         Attachments: HADOOP-4210.patch, HADOOP-4210.patch, HADOOP4210.patch
>
>
> During compilation - findbugs generates several warnings that indicates bugs in the implementation of equals method. One of the example of this report is:
> Bug type EQ_GETCLASS_AND_CLASS_CONSTANT (click for details)
> In class org.apache.hadoop.mapred.ID
> In method org.apache.hadoop.mapred.ID.equals(Object)
> At ID.java:[line 66]
> Value doesn't work for subtypes
> This class has an equals method that will be broken if it is inherited by subclasses. It compares a class literal with the class of the argument (e.g., in class Foo it might check if Foo.class == o.getClass()). It is better to check if this.getClass() == o.getClass().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HADOOP-4210) Findbugs warnings are printed related to equals implementation of several classes

Posted by "Chris Douglas (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HADOOP-4210?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chris Douglas updated HADOOP-4210:
----------------------------------

    Hadoop Flags: [Incompatible change, Reviewed]  (was: [Incompatible change])

bq. Do ID and its subclasses need to be a public classes? All can probably be package-private
This is wrong; subpackages need access to methods on these IDs. Assuming all test cases pass, +1.

> Findbugs warnings are printed related to equals implementation of several classes
> ---------------------------------------------------------------------------------
>
>                 Key: HADOOP-4210
>                 URL: https://issues.apache.org/jira/browse/HADOOP-4210
>             Project: Hadoop Core
>          Issue Type: Bug
>            Reporter: Suresh Srinivas
>            Assignee: Suresh Srinivas
>             Fix For: 0.20.0
>
>         Attachments: HADOOP-4210.patch, HADOOP-4210.patch, HADOOP4210.patch
>
>
> During compilation - findbugs generates several warnings that indicates bugs in the implementation of equals method. One of the example of this report is:
> Bug type EQ_GETCLASS_AND_CLASS_CONSTANT (click for details)
> In class org.apache.hadoop.mapred.ID
> In method org.apache.hadoop.mapred.ID.equals(Object)
> At ID.java:[line 66]
> Value doesn't work for subtypes
> This class has an equals method that will be broken if it is inherited by subclasses. It compares a class literal with the class of the argument (e.g., in class Foo it might check if Foo.class == o.getClass()). It is better to check if this.getClass() == o.getClass().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HADOOP-4210) Findbugs warnings are printed related to equals implementation of several classes

Posted by "Chris Douglas (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-4210?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12634340#action_12634340 ] 

Chris Douglas commented on HADOOP-4210:
---------------------------------------

bq. For class comparison, should we use equals(...) instead of ==? Otherwise, I am afraid it won't work in dynamic class loading.

java.lang.Class doesn't override equals, so it uses Object::equals, which does exactly this.

> Findbugs warnings are printed related to equals implementation of several classes
> ---------------------------------------------------------------------------------
>
>                 Key: HADOOP-4210
>                 URL: https://issues.apache.org/jira/browse/HADOOP-4210
>             Project: Hadoop Core
>          Issue Type: Bug
>            Reporter: Suresh Srinivas
>            Assignee: Suresh Srinivas
>             Fix For: 0.20.0
>
>         Attachments: HADOOP-4210.patch, HADOOP-4210.patch, HADOOP4210.patch
>
>
> During compilation - findbugs generates several warnings that indicates bugs in the implementation of equals method. One of the example of this report is:
> Bug type EQ_GETCLASS_AND_CLASS_CONSTANT (click for details)
> In class org.apache.hadoop.mapred.ID
> In method org.apache.hadoop.mapred.ID.equals(Object)
> At ID.java:[line 66]
> Value doesn't work for subtypes
> This class has an equals method that will be broken if it is inherited by subclasses. It compares a class literal with the class of the argument (e.g., in class Foo it might check if Foo.class == o.getClass()). It is better to check if this.getClass() == o.getClass().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HADOOP-4210) Findbugs warnings are printed related to equals implementation of several classes

Posted by "Suresh Srinivas (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HADOOP-4210?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12632775#action_12632775 ] 

Suresh Srinivas commented on HADOOP-4210:
-----------------------------------------

Patch passed all the unit tests. The number of findbugs warning for "Correctness Warnings" reduced from 18 to 8.

Here is the result of test-patch:
{noformat}
      [exec] -1 overall.  
 
      [exec]     +1 @author.  The patch does not contain any @author tags.
 
      [exec]     -1 tests included.  The patch doesn't appear to include any new or modified tests.
      [exec]                         Please justify why no tests are needed for this patch.
 
      [exec]     +1 javadoc.  The javadoc tool did not generate any warning messages.
 
      [exec]     +1 javac.  The applied patch does not increase the total number of javac compiler warnings.
 
      [exec]     +1 findbugs.  The patch does not introduce any new Findbugs warnings.
{noformat}

> Findbugs warnings are printed related to equals implementation of several classes
> ---------------------------------------------------------------------------------
>
>                 Key: HADOOP-4210
>                 URL: https://issues.apache.org/jira/browse/HADOOP-4210
>             Project: Hadoop Core
>          Issue Type: Bug
>            Reporter: Suresh Srinivas
>            Assignee: Suresh Srinivas
>             Fix For: 0.19.0
>
>         Attachments: HADOOP-4210.patch, HADOOP-4210.patch, HADOOP4210.patch
>
>
> During compilation - findbugs generates several warnings that indicates bugs in the implementation of equals method. One of the example of this report is:
> Bug type EQ_GETCLASS_AND_CLASS_CONSTANT (click for details)
> In class org.apache.hadoop.mapred.ID
> In method org.apache.hadoop.mapred.ID.equals(Object)
> At ID.java:[line 66]
> Value doesn't work for subtypes
> This class has an equals method that will be broken if it is inherited by subclasses. It compares a class literal with the class of the argument (e.g., in class Foo it might check if Foo.class == o.getClass()). It is better to check if this.getClass() == o.getClass().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.