commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benedikt Ritter <brit...@apache.org>
Subject Re: [digester] Should popping the last object off the stack update the root?
Date Fri, 02 Jan 2015 20:03:21 GMT
Hello Barney,

thanks for the report. The normal way for contributing code is by attaching
a patch to jira [1]. Don't forget to include some unit tests ;-)

TIA!
Benedikt

[1] https://issues.apache.org/jira

2015-01-02 12:26 GMT+01:00 Barney <b002913@bsxl.com>:

> 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-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message