You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Lewis, Cory (Genworth)" <co...@genworth.com> on 2005/10/27 16:44:35 UTC

[configuration] PropertiesConfiguration include functionality broken

Hi.
 
I believe I've found a bug in commons-configuration 1.1. Basically,
PropertiesConfiguration will not actually include files in an include
directive until the original properties file has been reloaded.
 
An example:
 
[prefs.properties]
include=other.properties
foo=pref test1
 
[other.properties]
bar=other test2
 
the test:
 
PropertiesConfiguration config = new
PropertiesConfiguration("prefs.properties");
config.setReloadingStrategy(new FileChangedReloadingStrategy());
 
int current = 0;
 
while(current < 2){
    System.out.println(config.getString("foo"));
    System.out.println(config.getString("bar"));
    current++;
    Thread.sleep(10000);
}
 
If this is run, and no files are touched, you'll get
pref test1
null
pref test1
null
 
If, however, you make a change to prefs.properties so the file gets
reread during the sleep, you'll get
pref test1
null 
pref test1
other test2
 
 
If you take out the reload strategy and run this against configuration
1.0, it works as expected. 
It may be noted that I have applied the patch supplied in bug 34289 by
Oliver Heger.
http://issues.apache.org/bugzilla/show_bug.cgi?id=34289
 
I'd be happy to file a bug report, but someone else who can be more
concise may want to do it.
 
In the meantime, if any one has a quick fix for this, it would be
greatly appreciated. 
 
 
 
 
________________________
Cory Lewis
IT Specialist
434-522-2120
 

Re: [configuration] PropertiesConfiguration include functionality broken

Posted by Oliver Heger <he...@med.uni-marburg.de>.
Lewis, Cory (Genworth) schrieb:
> Hi.
>  
> I believe I've found a bug in commons-configuration 1.1. Basically,
> PropertiesConfiguration will not actually include files in an include
> directive until the original properties file has been reloaded.
>  
> An example:
>  
> [prefs.properties]
> include=other.properties
> foo=pref test1
>  
> [other.properties]
> bar=other test2
>  
> the test:
>  
> PropertiesConfiguration config = new
> PropertiesConfiguration("prefs.properties");
> config.setReloadingStrategy(new FileChangedReloadingStrategy());
>  
> int current = 0;
>  
> while(current < 2){
>     System.out.println(config.getString("foo"));
>     System.out.println(config.getString("bar"));
>     current++;
>     Thread.sleep(10000);
> }
>  
> If this is run, and no files are touched, you'll get
> pref test1
> null
> pref test1
> null
>  
> If, however, you make a change to prefs.properties so the file gets
> reread during the sleep, you'll get
> pref test1
> null 
> pref test1
> other test2
>  
>  
> If you take out the reload strategy and run this against configuration
> 1.0, it works as expected. 
> It may be noted that I have applied the patch supplied in bug 34289 by
> Oliver Heger.
> http://issues.apache.org/bugzilla/show_bug.cgi?id=34289
>  
> I'd be happy to file a bug report, but someone else who can be more
> concise may want to do it.
>  
> In the meantime, if any one has a quick fix for this, it would be
> greatly appreciated. 
>  
>  
Cory,

from your comments I read that you do not use the current version of 
configuration (i.e. the version in svn). In addition to the patch you 
mention there have been other changes to PropertiesConfiguration. Some 
of them also affected the include mechanism. I remember one issue with 
the base path not being correctly set, which makes including files fail.

So, could you please give the current svn trunk a try and check if the 
problem persists? If this is the case, I will have a look.

Thanks.
Oliver

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