RFR : 7144488 StackOverflowError occurres on list via Collections.synchronizedList(List) (original) (raw)
Alan Bateman Alan.Bateman at oracle.com
Thu Feb 23 09:55:26 UTC 2012
- Previous message: RFR : 7144488 StackOverflowError occurres on list via Collections.synchronizedList(List)
- Next message: RFR : 7144488 StackOverflowError occurres on list via Collections.synchronizedList(List)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 23/02/2012 02:44, David Holmes wrote:
All of the SynchronizedX.equals methods should be fixed ie SynchronizedSet, SynchronizedList and SynchronizedMap. It should always be valid to ask if a.equals(a). The idiomatic form used elsewhere (CheckedXXX) is: public boolean equals(Object o) { return o == this || list.equals(o); } I'm not a fan of collections containing themselves, but I think it is simple to fix contains(o)/contains[Key]|Value and remove(o) in a similar way. Though none of the wrapped collections currently handle that case, so I'm okay with not addressing this part. I don't see the recursion potential in hashCode() in the wrappers. The hashCode of a Set requires summing the hash codes of each of the elements so it can't work for the case that a set contains itself. Anyway, I think the best we can do it to have the equals methods use the above form. I wasn't aware of the warning in List that Sean pointed out and maybe there should be similar warnings elsewhere.
-Alan
- Previous message: RFR : 7144488 StackOverflowError occurres on list via Collections.synchronizedList(List)
- Next message: RFR : 7144488 StackOverflowError occurres on list via Collections.synchronizedList(List)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]