Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 38870 invoked from network); 8 Apr 2011 17:00:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 8 Apr 2011 17:00:51 -0000 Received: (qmail 26767 invoked by uid 500); 8 Apr 2011 17:00:47 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 26587 invoked by uid 500); 8 Apr 2011 17:00:46 -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 26306 invoked by uid 99); 8 Apr 2011 17:00:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Apr 2011 17:00:46 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Apr 2011 17:00:43 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 02769988F0 for ; Fri, 8 Apr 2011 17:00:06 +0000 (UTC) Date: Fri, 8 Apr 2011 17:00:06 +0000 (UTC) From: "Fabien Nisol (JIRA)" To: issues@commons.apache.org Message-ID: <735610304.44189.1302282006006.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <876756733.24995.1301593325782.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Resolved] (CONFIGURATION-444) SubsetConfiguration does not properly handle interpolation when used on a HierarchicalConfiguration MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/CONFIGURATION-444?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Fabien Nisol resolved CONFIGURATION-444. ---------------------------------------- Resolution: Not A Problem The SubsetConfiguration should not be directly used as stated in comments > SubsetConfiguration does not properly handle interpolation when used on a HierarchicalConfiguration > --------------------------------------------------------------------------------------------------- > > Key: CONFIGURATION-444 > URL: https://issues.apache.org/jira/browse/CONFIGURATION-444 > Project: Commons Configuration > Issue Type: Bug > Components: Interpolation > Affects Versions: 1.6 > Environment: all > Reporter: Fabien Nisol > > Imaging next text files: > {code:xml} > > a_value > > attr1="${var}" > attr2="attr2" > /> > > > {code} > {code:java} > ... > XMLConfiguration config2 = new XMLConfiguration("test/test2.xml"); > Configuration subset2 = config2.subset("prop2"); > Configuration subset3 = new SubsetConfiguration(subset2,"prop"); > System.err.println(subset3.getString("[@attr1]")) > ... > {code} > the result is wrong: > {code} > ${var} > {code} > it should be: > {code} > a_value > {code} > I think the problem is related to the _interpolate()_ method in SubsetConfiguration(), which seems to involve some kind of recursive trick that seem overcomplicated (and inefficient, since it's creating unnecessary SubsetConfiguration).. > But maybe I'm missing something. > {code} > protected Object interpolate(Object base) > { > if (delimiter == null && "".equals(prefix)) > { > return super.interpolate(base); > } > else > { > SubsetConfiguration config = new SubsetConfiguration(parent, ""); > return config.interpolate(base); > } > } > {code} > I think the code below would be more appropriate: > {code} > protected Object interpolate(Object base) > { > if(parent instanceof AbstractConfiguration) > { > return ((AbstractConfiguration)parent).interpolate(base); > } else { > return base; > } > } > {code} > There's no reason to try interpolation if the parent is not implementing interpolation. > This brings other questions about the whole interpolation thing. I really wonder why the _Configuration_ interface does not define that method, leaving or the the option to implementation to actually implement it. But that is another debate. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira