Request for review: 7123229: (coll) EnumMap.containsValue(null) returns true (original) (raw)
Alan Bateman Alan.Bateman at oracle.com
Tue Jan 10 08:57:41 UTC 2012
- Previous message: Request for review: 7123229: (coll) EnumMap.containsValue(null) returns true
- Next message: Request for review: 7123229: (coll) EnumMap.containsValue(null) returns true
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 10/01/2012 01:05, Neil Richards wrote:
Hi all, When proposing the change for 6312706 [1], I erroneously managed to convince myself (and others!) that it would be safe to use 'new Integer(0)' for java.util.EnumMap.NULL (the object used to mark null values for entries in the map) [2].
This was on the basis that I thought it was only compared by identity. However, on closer inspection, this turns out not to be the case. 7123229 was raised to report the bug that was introduced based on this invalid assumption. I've created a webrev with a suggested fix for 7123229 [3], which changes NULL to be an Object which: * will only return 'true' from equals(Object) for itself * returns 0 from hashCode() For good measure, it also returns a sensible value from toString(). Please review this fix and let me know your thoughts, Looks okay to me too. In the test I probably would have used if (!map.containsValue(...)) rather than if (false == map.containsValue...)).
-Alan.
- Previous message: Request for review: 7123229: (coll) EnumMap.containsValue(null) returns true
- Next message: Request for review: 7123229: (coll) EnumMap.containsValue(null) returns true
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]