United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 6360946 (coll) SetFromMap.equals should perform identity check
6360946 : (coll) SetFromMap.equals should perform identity check

Details
Type:
Bug
Submit Date:
2005-12-08
Status:
Resolved
Updated Date:
2012-10-08
Project Name:
JDK
Resolved Date:
2006-03-23
Component:
core-libs
OS:
generic
Sub-Component:
java.util:collections
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:
6

Related Reports
Relates:

Sub Tasks

Description
Jason writes:

It seems that the SetFromMap.equals should first perform the identity check on 
itself before calling equals on the wrapped keyset.  The behavior would be 
more consistent with the other collections.

                                    

Comments
SUGGESTED FIX

public void clear()               { m.clear(); }
-        public boolean equals(Object o)   { return keySet.equals(o); }
+        public boolean equals(Object o)   {
+	    return (o == this) || keySet.equals(o);
+	}
                                     
2005-12-08
EVALUATION

Indeed.  The check preserves the reflexive property of equals as 
an equivalence relation, when applied to concurrent collections.
                                     
2005-12-08



Hardware and Software, Engineered to Work Together