]
Manik Surtani updated JBCACHE-1412:
-----------------------------------
Fix Version/s: 1.4.1.SP10
(was: 1.4.X)
Marshaller uses equals() to test object equality instead of identity
when performing reference counting
-------------------------------------------------------------------------------------------------------
Key: JBCACHE-1412
URL:
https://jira.jboss.org/jira/browse/JBCACHE-1412
Project: JBoss Cache
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: Replication
Affects Versions: 1.4.1.SP9, 2.1.0.GA, 2.1.1.GA, 2.2.0.GA
Reporter: Brian Stansberry
Assignee: Manik Surtani
Priority: Critical
Fix For: 1.4.1.SP10, 2.2.1.CR1, 2.2.1.GA, 3.0.0.CR1, 3.0.0.GA
The marshalling logic in TreeCacheMarshaller140 uses a HashMap as store of objects
already written so it can replace subsequent writes of the same object with a magic
number. Use of a HashMap is incorrect, as magic number replacement should only occur if an
object with the same identity is detected, not one that just satisfies equals() but not
==.
Either a custom map that uses System.identityHashCode() for hashing and == instead of
equals() for equality is needed, or the map key should be System.identityHashCode(). Note
the Object.hashCode() javadocs do not absolutely guarantee uniqueness in
System.identityHashCode(), so a custom map is probably better:
"As much as is reasonably practical, the hashCode method defined by class Object
does return distinct integers for distinct objects. (This is typically implemented by
converting the internal address of the object into an integer, but this implementation
technique is not required by the JavaTM programming language.)"
Non-uniquenesss in System.identityHashCode() might be more of an issue in systems with
large heaps that can't be addressed with 32 bits.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: