[jboss-user] [JBossCache] - PojoCache 2.0: Bug in CacheApiUtil.exists?
chasta
do-not-reply at jboss.com
Sun Dec 10 13:40:03 EST 2006
Hi,
Please note the following code snippet from CacheApiUtil.java:
| public static boolean exists(CacheSPI cache, Fqn fqn, Object key)
| {
| if(cache.getCacheLoader() != null)
| {
| // Has cache loader
| return (cache.get(fqn, key) != null) ? true : false;
| }
|
| Node node = cache.getRoot().getChild(fqn);
| if(node == null) return false;
| Map map = node.getData();
| return (map.values().contains(key)) ? true: false; // <-- HERE
| }
|
(From latest CVS version of JBossCache 2.0)
Why is the contains() called on the map values and not on the map keys? If I understand the intention correctly, isn't this a bug?
This affects the following snippet:
>From CacheFieldInterceptor.java:
| private boolean isPojoDetached(Invocation invocation)
| {
| boolean detached = false;
|
| // PojoInstance.KEY is "PojoInstance"
| // This will always be false, since we're giving it the key and it looks for
| // the value
| if(!CacheApiUtil.exists(cache_, fqn_, PojoInstance.KEY)) // <-- HERE
| {
| detached = true;
| Object obj = invocation.getTargetObject();
| ...
|
It affects our usage of the cache - the cache throws us spurious exceptions about objects being detached from it (PojoCacheAlreadyDetachedException. We're using local mode with optimistic locking).
Is this a bug? Or perhaps I'm missing something? And if so, any idea why are we getting these spurious exceptions?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3992555#3992555
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3992555
More information about the jboss-user
mailing list