Hi,

There seems to me to be a bit of a discrepancy between the way push() and pop() interact with the root object when stack actions are used to change the object.

* If a stack action changes the root object when being pushed onto the stack then the root reference is set to the changed object. * If a stack action changes the root object when being popped from the stack then the root reference is not updated.

I'm not sure if this is intended behaviour or not, but it caught me out when trying to use stack actions for a specific problem, as I expected digester.parse() to return the value from stackAction.onPop(). I solved my specific problem a different way so this no longer affects me, but thought I'd ask anyway.

So should Digester.pop() be updated to do this?

    public <T> T pop()
    {
        try
        {
            T popped = this.<T> npeSafeCast( stack.pop() );
            if ( stackAction != null )
            {
                popped = stackAction.onPop( this, null, popped );
            }
++          if ( stack.size() == 0 )
++          {
++              root = popped;
++          }
            return popped;
        }
        catch ( EmptyStackException e )
        {
            log.warn( "Empty stack (returning null)" );
            return ( null );
        }
    }

Cheers,

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to