Uploaded image for project: 'Commons Configuration'
  1. Commons Configuration
  2. CONFIGURATION-595

need optional include without exception

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Won't Fix
    • 2.x, 1.10
    • None
    • Expression engine
    • None

    Description

      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!

      Attachments

        Activity

          People

            Unassigned Unassigned
            ryenus ryenus
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: