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 34289] - [configuration] FileChangedReloadingStrategy fails to properly detect file change
Date Tue, 05 Apr 2005 02:56:44 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=34289>.
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=34289





------- Additional Comments From eric.lee@genworth.com  2005-04-05 04:56 -------
The latest example exposes another bug...

If the fully qualified properties file name is specified:

PropertiesConfiguration config= new PropertiesConfiguration
("d:/tmp/commons.properties");

and the ouput statement is:

System.out.println((new Date()) + " : " + strategy.reloadingRequired() + " : "
+ config.getString("prop1"));

The updated propery is not retrieved.  It appears that 
strategy.reloadingRequired() sets a flag and the next property retrieval 
request does not actaully reload the file.  Commenting out 
strategy.reloadingRequired() allows the updated property to be reloaded.

When only the file name is suppled and the file is loaded from a location in 
the classpath, commenting out strategy.reloadingRequired()  still does not 
cause the updated property to be reloaded, e.g.:  

PropertiesConfiguration config= new PropertiesConfiguration
("commons.properties");


The problem appears to be caused by the basePath member of 
AbstractFileConfiguration not getting set properly after the properties file 
URL is obtained from the classpath.  I was able to correct the problem by 
modifying AbstractFileConfiguration.load(String) from:


    public void load(String fileName) throws ConfigurationException
    {
        try
        {
            URL url = ConfigurationUtils.locate(basePath, fileName);
            if (url == null)
            {
                throw new ConfigurationException("Cannot locate configuration 
source " + fileName);
            }
            load(url);
        }
        catch (ConfigurationException e)
        {
            throw e;
        }
        catch (Exception e)
        {
            throw new ConfigurationException(e.getMessage(), e);
        }
    }

to: 

    public void load(String fileName) throws ConfigurationException
    {
        try
        {
            URL url = ConfigurationUtils.locate(basePath, fileName);
            if (url == null)
            {
                throw new ConfigurationException("Cannot locate configuration 
source " + fileName);
            }
            if(null == basePath){
            	setFile(new File(url.getFile()));
            }
            load(url);
        }
        catch (ConfigurationException e)
        {
            throw e;
        }
        catch (Exception e)
        {
            throw new ConfigurationException(e.getMessage(), e);
        }
    }



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