[JBoss JIRA] (JBCACHE-398) Cached collections don't handle null values correctly
by Scott Marlow (JIRA)
[ https://issues.jboss.org/browse/JBCACHE-398?page=com.atlassian.jira.plugi... ]
Scott Marlow closed JBCACHE-398.
--------------------------------
> 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
12 years, 4 months
[JBoss JIRA] (JBCACHE-398) Cached collections don't handle null values correctly
by Scott Marlow (JIRA)
[ https://issues.jboss.org/browse/JBCACHE-398?page=com.atlassian.jira.plugi... ]
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
12 years, 4 months
[JBoss JIRA] (JBCACHE-399) CachedMapImpl doesn't store key objects
by Scott Marlow (JIRA)
[ https://issues.jboss.org/browse/JBCACHE-399?page=com.atlassian.jira.plugi... ]
Scott Marlow closed JBCACHE-399.
--------------------------------
> CachedMapImpl doesn't store key objects
> ---------------------------------------
>
> Key: JBCACHE-399
> URL: https://issues.jboss.org/browse/JBCACHE-399
> 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: 2.0.0.GA
>
>
> The current implementation of CachedMapImpl forces all keys to be string values. In CachedMapImpl we have:
> public Object put(Object key, Object value)
> {
> return cache_.putObject(AopUtil.constructFqn(getFqn(), key), value); // removed try/catch for brevity
> }
> The current implementation of AopUtil.constructFqn() essentially calls key.toString(). Therefore, calling keySet() on the map will always return a set of String objects, which is usually not what the user intended.
> I have a fix that stores key objects under a "key" FQN, and value objects under a "value" FQN. So, rather than calling getFqn() I now call either getValueFqn() or getKeyFqn() as appropriate. keySet() now acts the same way as values(), returning the correct object type for each key. This also requires a change to CollectionClassHandler.collectionObjectPut(), which now directly uses the Map.put() method to pre-populate the map, rather than directly adding entries to the cache.
> Note that the unit tests currently only use String objects as keys, so they all pass. A few more unit tests need to be added to cover testing key types.
--
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
12 years, 4 months
[JBoss JIRA] (JBCACHE-399) CachedMapImpl doesn't store key objects
by Scott Marlow (JIRA)
[ https://issues.jboss.org/browse/JBCACHE-399?page=com.atlassian.jira.plugi... ]
Scott Marlow reassigned JBCACHE-399:
------------------------------------
Assignee: Scott Marlow (was: Scott Marlow (Novell))
> CachedMapImpl doesn't store key objects
> ---------------------------------------
>
> Key: JBCACHE-399
> URL: https://issues.jboss.org/browse/JBCACHE-399
> 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: 2.0.0.GA
>
>
> The current implementation of CachedMapImpl forces all keys to be string values. In CachedMapImpl we have:
> public Object put(Object key, Object value)
> {
> return cache_.putObject(AopUtil.constructFqn(getFqn(), key), value); // removed try/catch for brevity
> }
> The current implementation of AopUtil.constructFqn() essentially calls key.toString(). Therefore, calling keySet() on the map will always return a set of String objects, which is usually not what the user intended.
> I have a fix that stores key objects under a "key" FQN, and value objects under a "value" FQN. So, rather than calling getFqn() I now call either getValueFqn() or getKeyFqn() as appropriate. keySet() now acts the same way as values(), returning the correct object type for each key. This also requires a change to CollectionClassHandler.collectionObjectPut(), which now directly uses the Map.put() method to pre-populate the map, rather than directly adding entries to the cache.
> Note that the unit tests currently only use String objects as keys, so they all pass. A few more unit tests need to be added to cover testing key types.
--
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
12 years, 4 months
[JBoss JIRA] (JBCACHE-498) Replication issue with Collection proxy using Iterators
by Scott Marlow (JIRA)
[ https://issues.jboss.org/browse/JBCACHE-498?page=com.atlassian.jira.plugi... ]
Scott Marlow reassigned JBCACHE-498:
------------------------------------
Assignee: Scott Marlow (was: Scott Marlow (Novell))
> Replication issue with Collection proxy using Iterators
> -------------------------------------------------------
>
> Key: JBCACHE-498
> URL: https://issues.jboss.org/browse/JBCACHE-498
> Project: JBoss Cache
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Affects Versions: 1.2.4SP1
> Reporter: prateek mathur
> Assignee: Scott Marlow
> Fix For: 1.3.0.GA
>
>
> There is an issue in replicating "updated" changes in the following scenario:
> Code:
> Map proxyMap=(Map)cache.geObject("/aop/mymap");
> Set set=proxyMap.keySet();
> Iterator setIterator=set.iterator();
> while(setIterator.hasNext()){
> Object obj=setIterator.next();
> if(obj.someCondition()==true){
> iterator.remove();
> }
> }
>
> So when the iterator.remove() is called , it will remove the object from the set and the corresponding "key" and "value" from the HashMap.
> But the PROBLEM is it does not REPLICATE this removal.Since the HashMap was affected ultimately so replication should have happened, but it doesnt.
> However if explicity called map.remove("key"), the removal is replicated to the other nodes in the cluster.
> Is there any workaround for this??
--
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
12 years, 4 months