1 Reply Latest reply on Nov 10, 2004 6:42 AM by Bela Ban

    Remote TreeCacheListener Not Notified On remove(fqn, key) Ca

    Jimmy Wilson Apprentice

      Due to the issues I had with the TreeCacheView class, I wrote a command line implementation of TreeCacheListener. In doing so, I happened upon a quirk. It turns out that TreeCacheListener instances are not notified when the remove(fqn, key) method is invoked on remote instances. I have not tested with a listener that is local to the cache, but in looking at the code, I think that the result might be the same.

      Using the JBossCache 1.1 tagged version of TreeCache I tracked the actual removal (on a remote instance from the remove invocation) to line 2517. In the latest revision, the line is 2576. The method containing these lines of code never issues a nodeModified event to the listeners, however it is a bit more complicated because the method does issue nodeRemoved events. They are suppressed for the context of this call due to a boolean parameter on the method itself.

      Should invocations of remove(fqn, key) cause nodeModification events? It seems like they should, but the presence of the other (suppressed) events confuses me. I supposed this method is used for both the removal of nodes and of values from a node's map. Am I reading this correctly?

      For reference, the JBossCache 1.1 tagged version of TreeCache's _remove method is below. Line 2517 is the line containing old_value=n.remove(key).

      public Object _remove(GlobalTransaction tx, Fqn fqn, Object key,
       boolean create_undo_ops, boolean sendNodeEvent)
      throws LockingException, TimeoutException {
       Node n=null;
       MethodCall undo_op=null;
       Object old_value=null;
       log.debug("_remove(" + tx + ", \"" + fqn + "\", " + key + ")");
       try {
       // Find the node. This will lock it (if <tt>locking</tt> is true) and
       // add the temporarily created parent nodes to the TX's node list if tx != null)
       n=findNode(fqn, true, locking, tx, NODE_WRITE);
       if(n == null) {
       log.error("_remove(): node " + fqn + " not found");
       return null;
       // create a compensating method call (reverting the effect of
       // this modification) and put it into the TX's undo list.
       if(tx != null && create_undo_ops && old_value != null) {
       undo_op=new MethodCall(put_key_val_method,
       new Object[]{tx, fqn, key, old_value,
       new Boolean(false)});
       // 1. put undo-op in TX' undo-operations list (needed to rollback TX)
       tx_table.addUndoOperation(tx, undo_op);
       return old_value;
       finally { // we always unlock when no TX is present (lock-update-unlock)
       if(tx == null && locking == true)
       releaseLocks(tx, fqn);