[jboss-user] [JBossCache] - Cross-reference problem

finnam do-not-reply at jboss.com
Tue Nov 7 09:42:35 EST 2006


Hi guys!

We've met a problem with JBoss cache and we don't know if it's a bug or usage problem.
We have an annotated User class wich has an ArrayList buddies property. We put two instances of User class to the cache and each instance has a reference to another one from the buddies list. The code is like this:

  | User user1 = new User();
  | User user2 = new User();
  | cache.putObject(user1.getFqn(), user1);
  | cache.putObject(user2.getFqn(), user2);
  | //skipped
  | user1.getBuddies().add(user2);
  | //skipped
  | user2.getBuddies().add(user1);
  | 

On some event we are removing user1 from the cache:

  | user2.getBuddies().remove(user1);
  | cache.removeObject(user1.getFqn());
  | 

And then we are putting it again: 

  | cache.putObject(user1.getFqn(), user1);
  | user2.getBuddies().add(user1);
  | 
This last line of code throws IllegalStateException with the following message:
AopInstance.incrementRefCount: source fgn /users/user1 is already present.

After a small debugging we added following befor removing user1 from cache: 
user1.getBuddies().clean();
And all the problems are gone. 

So, should we really remove all the references to the cached objects from user1 before removing it from the cache or it's a problem of illegal usage?

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

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



More information about the jboss-user mailing list