TimurMahammadov / google-collections

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

ReferenceMap ignores user-supplied delegate map during serialization. #99

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
ReferenceMap allows the user to specify a delegate map on construction, but  
during serialization the delegate is always replaced with a ConcurrentHashMap.  
This can lead to unexpected/surprising behavior.

Related to Issue #72.
Related to Issue #37.

Original issue reported on code.google.com by pline...@gmail.com on 17 Oct 2008 at 12:27

GoogleCodeExporter commented 9 years ago
Thanks for pointing that out this issue.

You mentioned http://code.google.com/p/google-collections/issues/detail?id=72, 
which
calls for removing the ReferenceMap constructor that takes an arbitrary backing 
map.
Once we do that, this problem will go away.

Besides, it's not clear how often people would want to serialize a ReferenceMap,
since soft and weak references in a deserialized map wouldn't be that useful.

Original comment by jared.l....@gmail.com on 17 Oct 2008 at 12:51

GoogleCodeExporter commented 9 years ago
Yes, removing that constructor would be ideal.

Should ReferenceMap even be "Serializable" given how odd it would be to 
serialize 
one?  Is it only serializable for the case of 'STRONG' keys with 'STRONG' 
values?  Or 
as a convenience for when it would otherwise have to be a transient field in 
some 
other class?

Original comment by pline...@gmail.com on 21 Oct 2008 at 1:19

GoogleCodeExporter commented 9 years ago
As I understand it, the main reason for making ReferenceMap serializable is so
frameworks, like servlets, that require serializability can use it. Perhaps 
someone
who's more familiar with that code could provide more insight.

Original comment by jared.l....@gmail.com on 21 Oct 2008 at 1:27

GoogleCodeExporter commented 9 years ago
I modified ReferenceMap so serialization throws an 
UnsupportedOperationException when
the instance has a custom backing map. A noisy failure is better than surprising
behavior.

Original comment by jared.l....@gmail.com on 24 Oct 2008 at 12:28

GoogleCodeExporter commented 9 years ago
Agreed.  That's great!

Original comment by pline...@gmail.com on 25 Oct 2008 at 2:51

GoogleCodeExporter commented 9 years ago

Original comment by kevin...@gmail.com on 29 Dec 2008 at 8:41