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 89AAA1061D for ; Wed, 21 Jan 2015 20:43:35 +0000 (UTC) Received: (qmail 8304 invoked by uid 500); 21 Jan 2015 20:43:35 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 8207 invoked by uid 500); 21 Jan 2015 20:43:35 -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 8195 invoked by uid 99); 21 Jan 2015 20:43:35 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Jan 2015 20:43:35 +0000 Date: Wed, 21 Jan 2015 20:43:35 +0000 (UTC) From: "Oliver Heger (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CONFIGURATION-595) need optional include without exception 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-595?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14286225#comment-14286225 ] Oliver Heger commented on CONFIGURATION-595: -------------------------------------------- It is correct that {{PropertiesConfiguration}} does not support optional includes. However, you can achieve something similar - and more flexible and powerful - with {{CombinedConfigurationBuilder}} (or {{DefaultConfigurationBuilder}} if you are still using version 1.10). This class allows constructing a combined configuration from an arbitrary number of configuration sources. Optional sources are supported as well. This is described in the user's guide at http://commons.apache.org/proper/commons-configuration/userguide/howto_combinedbuilder.html#Optional_configuration_sources Please have a look and tell us whether this fits your needs. I am a bit reluctant of extending the include mechanism of {{PropertiesConfiguration}} because it is a specific feature of this class and not supported by other configuration implementations - especially if combined configuration sources offer a super set of the functionality available. > need optional include without exception > --------------------------------------- > > Key: CONFIGURATION-595 > URL: https://issues.apache.org/jira/browse/CONFIGURATION-595 > Project: Commons Configuration > Issue Type: Improvement > Components: Expression engine > Affects Versions: 2.x, 1.10 > Reporter: ryenus > > I'm trying to include a server local properties file during initialization of a distributed application. > The file to be included might not exist on some of the servers, and this should be fine in terms of our application logic. > But this is not possible with commons configuration, inside org.apache.commons.configuration.PropertiesConfiguration.loadIncludeFile(String), when an included file doesn't exist, namely the resolved url would be null, it always throws a ConfigurationException. > See: https://github.com/apache/commons-configuration/blob/trunk/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java#L1414 > This might be good to ensure configuration integrity, but looking around, for bash, ~/.bashrc is optional, for maven, ~/.m2/settings.xml is optional, I wish there could be a way to do the same in commons configurations. > One way is to skip the exception, and print a warning to stderr (or some better logging options). > Alternatively, an `optionalInclude` key can be introduced to serve this purpose. > Thanks! -- This message was sent by Atlassian JIRA (v6.3.4#6332)