[jbosscache-issues] [JBoss JIRA] Resolved: (JBCACHE-1412) Marshaller uses equals() to test object equality instead of identity when performing reference counting

Manik Surtani (JIRA) jira-events at lists.jboss.org
Tue Sep 23 11:00:20 EDT 2008


     [ https://jira.jboss.org/jira/browse/JBCACHE-1412?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Manik Surtani resolved JBCACHE-1412.
------------------------------------

    Resolution: Done


> 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: 3.0.0.CR1, 3.0.0.GA, 1.4.X, 2.X
>
>
> 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: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jbosscache-issues mailing list