]
Manik Surtani reassigned JBCACHE-401:
-------------------------------------
Assignee: Jason T. Greene (was: Manik Surtani)
AOP Collection CacheSetImpl.add needs to be atomic
--------------------------------------------------
Key: JBCACHE-401
URL:
http://jira.jboss.com/jira/browse/JBCACHE-401
Project: JBoss Cache
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: PojoCache
Affects Versions: PojoCache
Reporter: Scott Marlow
Assigned To: Jason T. Greene
Fix For: 2.1.0.GA
CachedSetImpl.add() is not atomic (another thread could be adding the same value at the
same time and both threads get past the existence test).
Current code looks like this:
public boolean add(Object o)
{
if(keySet().contains(o)) // existance test is done under separate lock
return false;
try { // putObject is done under separate lock
cache_.putObject(new Fqn(getFqn(), o),o);
return true;
} catch (CacheException e) {
throw new NestedRuntimeException(e);
}
}
I think we need to do something like this:
public boolean add(Object o)
{
try {
cache_.putIfAbsent(new Fqn(getFqn(), o),o);
return true;
} catch (CacheException e) {
throw new NestedRuntimeException(e);
}
}
Will need new api support
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: