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

[configuration] ConfigurationFactory not working as expected with include path resolution

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.1
    • None
    • None
    • None
    • Operating System: All
      Platform: All

    • 35316

    Description

      Documentation states that ConfigurationFactory searches includes in a directory
      relative to the one including conf is located...

      Actually, some problem in various initializer methods of ConfigurationFactory
      makes it happen a way that is not natural.

      ConfigurationFactory() empty constructor sets the basePath to ".". This is okay,
      but when calling setConfigurationFileName,

      public void setConfigurationFileName(String configurationFileName)

      { File file = new File(configurationFileName).getAbsoluteFile(); this.configurationFileName = file.getName(); implicitBasePath = file.getParent(); }

      basePath is not reset to null... so a call to getBasePath will not return the
      implicitBasePath as stated.

      public String getBasePath()

      { String path = StringUtils.isEmpty(basePath) ? implicitBasePath : basePath; return StringUtils.isEmpty(path) ? "." : path; }

      using ConfigurationFactory(String configurationFileName) does not help, since it
      does not use setConfigurationFileName , so it does not set implicitBasePath

      public ConfigurationFactory(String configurationFileName)

      { this.configurationFileName = configurationFileName; }

      A work-around solution to these problems is to set the basePath to null
      explicitely after instanciation/setup...

      a possible correction is to modify the constructor and the setter like this:

      public ConfigurationFactory(String configurationFileName)

      { setConfigurationFileName(configurationFileName); }

      public void setConfigurationFileName(String configurationFileName)

      { File file = new File(configurationFileName).getAbsoluteFile(); this.configurationFileName = file.getName(); this.basePath = null; implicitBasePath = file.getParent(); }

      Attachments

        Activity

          People

            Unassigned Unassigned
            fabien.nisol@videotron.ca Fabien Nisol
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: