commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 35315] New: - ConfigurationFactory not working as expected with include path resolution
Date Fri, 10 Jun 2005 17:37:12 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=35315>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=35315

           Summary: ConfigurationFactory not working as expected with
                    include path resolution
           Product: Commons
           Version: 1.1.0
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: trivial
          Priority: P3
         Component: Configuration
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: fabien.nisol@videotron.ca


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();
    }

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message