TimurMahammadov / google-collections

Automatically exported from code.google.com/p/google-collections
Apache License 2.0
0 stars 0 forks source link

ReferenceMap's SoftValueReference, WeakValueReference .toString() methods not overridden #37

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
These internal classes in ReferenceMap throw AssertionErrors if their
hashCode() methods are invoked (ReferenceMap.java lines 540 and 584).  I'm
assuming this is because they are not intended to be used as map keys.  But
the default toString() method (it's not overridden in either case) invokes
this.hashCode(), so attempting to print these objects throws an
AssertionError as well.

I'm passing in a delegate ConcurrentHashMap in ReferenceMap's constructor
and overriding its remove() methods so that I know when an entry is removed
from the map.  I discovered this bug when I was doing a simple
System.out.println() on the values being removed.

Thanks,
Laird (ljnelson over at gmail.com)

Original issue reported on code.google.com by ljnelson on 13 Nov 2007 at 9:04

GoogleCodeExporter commented 9 years ago
Good find; I introduced that regression a few weeks ago.  We didn't really have 
tests
covering debugging scenarios like that.

I have to warn you that the ability to pass an arbitrary backing ConcurrentMap 
to a
ReferenceMap is something that may not survive to 1.0.  There are some 
trade-offs.

Original comment by kevin...@gmail.com on 13 Nov 2007 at 9:12

GoogleCodeExporter commented 9 years ago
No worries.  If you do remove the user-supplied-map-at-construction-time option,
could you kindly consider that callers (like me!) will often need to know when 
an
entry in the map is reclaimed/disappears/expires.

Best,
Laird

Original comment by ljnelson on 13 Nov 2007 at 9:37

GoogleCodeExporter commented 9 years ago

Original comment by kevin...@gmail.com on 27 May 2008 at 6:32

GoogleCodeExporter commented 9 years ago
ReferenceMap now obsolete.  If you have problems like this when debugging with
MapMaker, please file new issue.

Original comment by kevin...@gmail.com on 17 Mar 2009 at 5:19