|
Object Model Violation: Just One of Equals and Hashcode Defined Status: Draft Weakness ID: 581 (Weakness Base)Description Summary The software fails to maintain equal hashcodes for equal objects. Common Consequences Failure to uphold this invariant is likely to cause trouble if objects of this class are stored in a collection. If the objects of the class in question are used as a key in a Hashtable or if they are inserted into a Map or Set, it is critical that equal objects have equal hashcodes. Potential Mitigations Both Equals() and Hashcode() should be defined. Other Notes Java objects are expected to obey a number of invariants related to equality. One of these invariants is that equal objects must have equal hashcodes. In other words, if a.equals(b) == true then a.hashCode() == b.hashCode(). Relationships
Applicable Platforms Languages Java Time of Introduction ImplementationContent History Modifications Eric Dalci. Cigital. 2008-07-01. (External) updated Potential_Mitigations, Time_of_Introduction CWE Content Team. MITRE. 2008-09-08. (Internal) updated Common_Consequences, Relationships, Other_Notes Previous Entry Names Object Model Violation: Just One of Equals and Haschode Defined (changed 2008-01-30) |
|
|
|||