[jboss-dev-forums] [Design of JBossCache] - Re: PojoInstance: ref count & notification

jason.greene@jboss.com do-not-reply at jboss.com
Mon Apr 9 18:14:55 EDT 2007


"supi" wrote : Hi, I am trying to build an adapter on top of CacheListener to create (to me useful) Pojo notifications. Unfortunately, I cannot determine if a pojo is being multi-attached or detached because PojoInstance's ref count is the same in local pre and post notification (IMO a bug). The problem is in InternalHelper:
  | 

Can you expalin in more detail and possiblly show a code example of how you noticed this? InternalHelper does correctly dispatch to PojoInstance to increment the counter. There was however a bug I recently fixed that would cause any serializable object that was accessed on a remote node to possible see a stale copy.  Although keep in mind that currently notifications only trigger on the local node that produced the change.

anonymous wrote : 
  | It is stated that the method is not thread safe but the instance's incrementRefCount and decrement methods are in fact synchronized. So, can I just clone the instance, increment and put or do I need to synchronize the whole thing? Shouldn't it be locked anyway, where does this happen? 
  | 

You should not have to clone the instance. Does cloning fix the problem for you? If so you are likely seeing the bug I mentioned earlier (a current cvs checkout should solve the issue). As far as locking is concerned, there is an outter lock held by ObjectGraphHandler.

-Jason

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4035825#4035825

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4035825



More information about the jboss-dev-forums mailing list