commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Barney Barumba (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (DIGESTER-182) Popping the last object off the stack should update the root reference
Date Sat, 03 Jan 2015 02:51:34 GMT

     [ https://issues.apache.org/jira/browse/DIGESTER-182?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Barney Barumba updated DIGESTER-182:
------------------------------------
    Attachment: DIGESTER-182.patch

> Popping the last object off the stack should update the root reference
> ----------------------------------------------------------------------
>
>                 Key: DIGESTER-182
>                 URL: https://issues.apache.org/jira/browse/DIGESTER-182
>             Project: Commons Digester
>          Issue Type: Bug
>    Affects Versions: 3.2
>         Environment: Linux x_86_64, JDK 1.7.0_65
>            Reporter: Barney Barumba
>         Attachments: DIGESTER-182.patch
>
>
> There is 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.
> The attached patch fixes the digester to update the root reference when popping the last
element fron the stack. It simply adds 4 lines to Digester.pop()
> {code}
>     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 );
>         }
>     }
> {code}
> Patch also contains a test case: {{DigesterTestCase.testStackActionGetRoot()}}.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message