commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Heger (JIRA)" <j...@apache.org>
Subject [jira] Commented: (CONFIGURATION-253) FileConfiguration getFile(), getFileName(), getBasePath() are not always consistent
Date Wed, 25 Apr 2007 20:06:15 GMT

    [ https://issues.apache.org/jira/browse/CONFIGURATION-253?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12491750
] 

Oliver Heger commented on CONFIGURATION-253:
--------------------------------------------

The behavior since (I think) the 1.2 release is that a load() call sets the sourceURL if none
has been set so far. This is required for supporting features like auto save and reloading
strategies for configurations created this way (there is no hint in the docs that a source
must be set explicitly for using these features, so I assume this is alright). What my fix
does is to always keep the getFile() method in sync with the sourceURL; so if a sourceURL
exists, getFile() will now return a corresponding File object.

Note that the URL is only modified on an initial load() call, i.e. if already a source was
set, it won't be changed by a following load() call. This is intended. It allows for instance
the easy creation of combined configurations: you can call load() as often as you like on
a file-based configuration; the properties of the single sources will be accumulated. Then
you can save the accumulated properties to the original source.

> FileConfiguration getFile(), getFileName(), getBasePath() are not always consistent
> -----------------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-253
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-253
>             Project: Commons Configuration
>          Issue Type: Bug
>    Affects Versions: 1.3
>            Reporter: Thomas Wabner
>             Fix For: 1.5
>
>
> Taken from the maillinglist:
> > I have a properties configuration which is loaded without a problem.
> > Later in my application I will access the file which is aligned to 
> > this configuration.
> > 
> >  
> > 
> > final IFileConfiguration _productConf = 
> > _conf.getProductConfigurations().get(_productId);
> > 
> > log.debug("product conf file " + _productConf.getFile());
> > 
> > log.debug("product conf filename " + _productConf.getFileName());
> > 
> > log.debug("product conf base path " + _productConf.getBasePath());
> > 
> >  
> > 
> > The methods _productConf.getFile() and _productConf.getFileName() 
> > returning null but the getBasePath() returns a path which is correct 
> > (like file:/C:/Projects/workspace/myProject/project.properties). Seems 
> > for me like a bug because the PropertiesConfiguration is loaded 
> > correct and works.
> > 
> >  
> > 
> > By side: I have also set a file reloading strategy for this 
> > configuration.
> > 
> >  
> > 
> > Any ideas what's happen in this case or where I can find the problem? 
> > It would be nicer to get the File() instead the BasePath which has to 
> > be converted into a URL before I can access the whole properties file.
> > 
> >  
> > 
> > Thanks in advance,
> > 
> >  
> > 
> > - Thomas Wabner
> > 
> > 
> Thomas,
> you are right, the conversions between a base path, a file name, and a File are not always
consistent. How did you load the configuration (this determines, which internal fields are
set)?
> I would recommend to work with URLs, i.e. the method getURL(). A file-based configuration's
URL is always defined.
> If you like, you can open a Jira ticket for this problem.
> Thanks.
> Oliver
> The file is loaded in this way:
> _productConf = new ProductConfiguration();
> _productConf.load(FileTools.getPathForList(_propductPathList).getPath());
> means the load method gets an String and not an File.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
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