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 84D63D08E for ; Sat, 2 Feb 2013 18:30:13 +0000 (UTC) Received: (qmail 55264 invoked by uid 500); 2 Feb 2013 18:30:13 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 55000 invoked by uid 500); 2 Feb 2013 18:30:13 -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 54991 invoked by uid 99); 2 Feb 2013 18:30:13 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Feb 2013 18:30:13 +0000 Date: Sat, 2 Feb 2013 18:30:13 +0000 (UTC) From: "Oliver Heger (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CONFIGURATION-524) AbstractConfiguration does not interpolate correctly after cloning 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/CONFIGURATION-524?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13569612#comment-13569612 ] Oliver Heger commented on CONFIGURATION-524: -------------------------------------------- Thank you for the report. There have been some changes recently in the current development version in the field of interpolation. However, I am pretty sure that the problem still exists. > AbstractConfiguration does not interpolate correctly after cloning > ------------------------------------------------------------------ > > Key: CONFIGURATION-524 > URL: https://issues.apache.org/jira/browse/CONFIGURATION-524 > Project: Commons Configuration > Issue Type: Bug > Components: Build > Reporter: Juan Diego Gago Perez > Original Estimate: 24h > Remaining Estimate: 24h > > If you clone a Configuration, does not clone the StrSubstitutor when it has been instanced, so the cloned copy has the same StrSubstituor than the original composite. If you change a property in the original compoiste it is changed in the cloned copy. > Way to reproduce it : > {code} > public class SampleConfiguration { > public static void main(final String[] args) { > final String sentence = "SELECT * FORM TABLE WHERE YEAR=${year} and QUARTER=${quarter}"; > final CompositeConfiguration cp = new CompositeConfiguration(); > cp.addProperty("year", "2000"); > cp.addProperty("quarter", "2"); > final AbstractConfiguration clonedConfig = (AbstractConfiguration) ConfigurationUtils.cloneConfiguration(cp); > cp.setProperty("year", "2001"); > clonedConfig.setProperty("year", "2002"); > System.out.println("Original sentence " + PropertyConverter.interpolate(sentence, cp)); > System.out.println("Cloned sentence " + PropertyConverter.interpolate(sentence, clonedConfig)); > final AbstractConfiguration clonedConfig2 = (AbstractConfiguration) ConfigurationUtils.cloneConfiguration(cp); > cp.setProperty("year", "2003"); > clonedConfig2.setProperty("year", "2004"); > System.out.println("Original sentence " + PropertyConverter.interpolate(sentence, cp)); > System.out.println("Cloned (after interpolate with same strSubstitutor )sentence " > + PropertyConverter.interpolate(sentence, clonedConfig2)); > } > } > {code} > The solution can be to make in the following ways: > Make the clone of the strSubstitutor in the AbstractConfigutration class. > Create a clone method inside the StrSubtitutor and invoke it from the AbstractConfiguration class. > Set null the strSubstituror when the clone method is invoked in the Abstract Configuration class. The next invocation to interpolate methos instances the strSubstitutor. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira