[jbosscache-issues] [JBoss JIRA] (JBCACHE-398) Cached collections don't handle null values correctly
Scott Marlow (JIRA)
jira-events at lists.jboss.org
Mon Aug 6 16:26:08 EDT 2012
[ https://issues.jboss.org/browse/JBCACHE-398?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Scott Marlow reassigned JBCACHE-398:
------------------------------------
Assignee: Scott Marlow (was: Scott Marlow (Novell))
> Cached collections don't handle null values correctly
> -----------------------------------------------------
>
> Key: JBCACHE-398
> URL: https://issues.jboss.org/browse/JBCACHE-398
> Project: JBoss Cache
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: Legacy POJO Cache
> Affects Versions: 1.2.4SP1
> Reporter: twundke
> Assignee: Scott Marlow
> Fix For: 1.3.0.GA
>
>
> When a null value is placed into a cached collection (CachedListImpl etc), the node for that element is removed from the cache. This is because TreeCacheAopDelegate._putObject() calls _removeObject() when provided with a null value.
> This behaviour breaks size() in the case where a collection allows null values to be stored (ArrayList, HashMap etc). The cache needs to explicitly store a null object (eg. org.jboss.util.Null) so that collections work as expected.
> I have a fix, which basically involves calling the following methods in the correct places:
> private Object toNullObject( Object aObject )
> {
> if ( aObject == null )
> {
> return Null.VALUE;
> } // if
> else
> {
> return aObject;
> } // else
> } // toNullObject
> private Object toNullValue( Object aObject )
> {
> if ( Null.VALUE.equals( aObject ) )
> {
> return null;
> } // if
> else
> {
> return aObject;
> } // else
> } // toNullObject
> So, for example, we can use:
> public Object get() {
> ...
> return toNullValue(cache_.getObject(...));
> }
> These methods should be placed in a common area to be called by each collection class. In addition to this, the CachedListImpl.checkArgument(Object) method should be removed.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jbosscache-issues
mailing list