3 Replies Latest reply on Nov 8, 2006 4:58 AM by Ben Wang

    Cross-reference problem

    Alexander Finn Newbie

      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);

      On some event we are removing user1 from the cache:

      And then we are putting it again:
      cache.putObject(user1.getFqn(), 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:

      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?