Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3FA0410AEB for ; Sat, 3 Jan 2015 02:51:34 +0000 (UTC) Received: (qmail 50299 invoked by uid 500); 3 Jan 2015 02:51:34 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 50198 invoked by uid 500); 3 Jan 2015 02:51:34 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 50187 invoked by uid 99); 3 Jan 2015 02:51:34 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Jan 2015 02:51:34 +0000 Date: Sat, 3 Jan 2015 02:51:34 +0000 (UTC) From: "Barney Barumba (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (DIGESTER-182) Popping the last object off the stack should update the root reference MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ 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 pop() > { > try > { > T popped = this. 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)