3 Replies Latest reply on Jan 25, 2005 1:44 AM by Bela Ban

    Patch for Node.java

    twundke Newbie

      I've been having a pretty in-depth look at the JBoss Cache code, and have found a number of small problems that I've fixed. I'm wasn't quite sure whether I should be using Jira or the forum to distribute patches, so I'll give the forum a go to start with.

      When a new cache starts and retrieves the transient state, Node objects are created--by the serialisation process--using the no-arg constructor. This constructor calls init(), which creates the IdentityLock object using "new IdentityLock(cache_,fqn)". The problem is that the fqn is never set on the IdentityLock (as the Node doesn't know the fqn at this point), which means that all IdentityLock messages show "null" as the fqn. Here's a patch on revision 1.60 that fixes the problem by creating the lock in readExternal() rather than in the constructor.

      *** Node.java.#.1.60 Thu Jan 20 10:45:55 2005
      --- Node.java Thu Jan 20 10:46:04 2005
      ***************
      *** 66,73 ****
      
       protected static final int INDENT=4;
      
       public Node() {
      ! init();
       }
      
       public Node(TreeCache cache) {
      --- 66,76 ----
      
       protected static final int INDENT=4;
      
      + /**
      + * This constructor is only to be used by serialization.
      + */
       public Node() {
      ! // No operation as the object is initialised by readExternal()
       }
      
       public Node(TreeCache cache) {
      ***************
      *** 494,501 ****
       parent=(Node)in.readObject();
       children=(Map)in.readObject();
       data=(Map)in.readObject();
      - }
      
      
       }
      -
      --- 497,505 ----
       parent=(Node)in.readObject();
       children=(Map)in.readObject();
       data=(Map)in.readObject();
      
      + // Perform default initialisation now that we have all of the required data
      + init();
      + }
      
       }


      Tim.