[ https://issues.apache.org/jira/browse/HADOOP-9124?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13568916#comment-13568916 ]
Surenkumar Nihalani commented on HADOOP-9124: --------------------------------------------- There is a very small issue: My latest attachment had this: {code} + // entrySets are now same + failureReason = "Two SortedMapWritables with same entry sets formed in different order have different hashcode"; + assertEquals(failureReason, mapA.hashCode(), mapB.hashCode()); + failureReason = "Two SortedMapWritables with same entry sets formed in different order are no longer equal"; + assertEquals(failureReason, mapA, mapB); + assertEquals(failureReason, mapB, mapA); {code} while Karthik and Tom, your latest attachments have this, {code} + // entrySets are now same + failureReason = "Two SortedMapWritables with same entry sets formed in different order are now different"; + assertEquals(failureReason, mapA.hashCode(), mapB.hashCode()); + assertTrue(failureReason, mapA.equals(mapB)); + assertTrue(failureReason, mapB.equals(mapA)); {code} I don't know how branches end up merging, but, since [~kkambatl] mentioned it during code review, so, I thought it was worth to point out. > SortedMapWritable violates contract of Map interface for equals() and > hashCode() > -------------------------------------------------------------------------------- > > Key: HADOOP-9124 > URL: https://issues.apache.org/jira/browse/HADOOP-9124 > Project: Hadoop Common > Issue Type: Bug > Components: io > Affects Versions: 1.1.1, 2.0.2-alpha > Reporter: Patrick Hunt > Assignee: Surenkumar Nihalani > Priority: Minor > Fix For: 2.0.3-alpha > > Attachments: hadoop-9124-branch1.patch, HADOOP-9124.patch, > HADOOP-9124.patch, HADOOP-9124.patch, HADOOP-9124.patch, HADOOP-9124.patch, > HADOOP-9124.patch, HADOOP-9124.patch, HADOOP-9124.patch, HADOOP-9124.patch, > HADOOP-9124.patch > > > This issue is similar to HADOOP-7153. It was found when using MRUnit - see > MRUNIT-158, specifically > https://issues.apache.org/jira/browse/MRUNIT-158?focusedCommentId=13501985&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13501985 > -- > o.a.h.io.SortedMapWritable implements the java.util.Map interface, however it > does not define an implementation of the equals() or hashCode() methods; > instead the default implementations in java.lang.Object are used. > This violates the contract of the Map interface which defines different > behaviour for equals() and hashCode() than Object does. More information > here: > http://download.oracle.com/javase/6/docs/api/java/util/Map.html#equals(java.lang.Object) > The practical consequence is that SortedMapWritables containing equal entries > cannot be compared properly. We were bitten by this when trying to write an > MRUnit test for a Mapper that outputs MapWritables; the MRUnit driver cannot > test the equality of the expected and actual MapWritable objects. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira