@ -288,20 +288,16 @@ public abstract class SystemReader {
* @since 5 . 1 . 9
* @since 5 . 1 . 9
* /
* /
public StoredConfig getUserConfig ( )
public StoredConfig getUserConfig ( )
throws IOException , ConfigInvalid Exception {
throws ConfigInvalidException , IO Exception {
FileBasedConfig c = userConfig . get ( ) ;
FileBasedConfig c = userConfig . get ( ) ;
if ( c = = null ) {
if ( c = = null ) {
userConfig . compareAndSet ( null ,
userConfig . compareAndSet ( null ,
openUserConfig ( getSystemConfig ( ) , FS . DETECTED ) ) ;
openUserConfig ( getSystemConfig ( ) , FS . DETECTED ) ) ;
c = userConfig . get ( ) ;
c = userConfig . get ( ) ;
} else {
// Ensure the parent is up to date
getSystemConfig ( ) ;
}
if ( c . isOutdated ( ) ) {
LOG . debug ( "loading user config {}" , userConfig ) ; //$NON-NLS-1$
c . load ( ) ;
}
}
// on the very first call this will check a second time if the system
// config is outdated
updateAll ( c ) ;
return c ;
return c ;
}
}
@ -319,20 +315,45 @@ public abstract class SystemReader {
* @since 5 . 1 . 9
* @since 5 . 1 . 9
* /
* /
public StoredConfig getSystemConfig ( )
public StoredConfig getSystemConfig ( )
throws IOException , ConfigInvalid Exception {
throws ConfigInvalidException , IO Exception {
FileBasedConfig c = systemConfig . get ( ) ;
FileBasedConfig c = systemConfig . get ( ) ;
if ( c = = null ) {
if ( c = = null ) {
systemConfig . compareAndSet ( null ,
systemConfig . compareAndSet ( null ,
openSystemConfig ( null , FS . DETECTED ) ) ;
openSystemConfig ( null , FS . DETECTED ) ) ;
c = systemConfig . get ( ) ;
c = systemConfig . get ( ) ;
}
}
if ( c . isOutdated ( ) ) {
updateAll ( c ) ;
LOG . debug ( "loading system config {}" , systemConfig ) ; //$NON-NLS-1$
c . load ( ) ;
}
return c ;
return c ;
}
}
/ * *
* Update config and its parents if they seem modified
*
* @param config
* configuration to reload if outdated
* @throws ConfigInvalidException
* if configuration is invalid
* @throws IOException
* if something went wrong when reading files
* /
private void updateAll ( Config config )
throws ConfigInvalidException , IOException {
if ( config = = null ) {
return ;
}
updateAll ( config . getBaseConfig ( ) ) ;
if ( config instanceof FileBasedConfig ) {
FileBasedConfig cfg = ( FileBasedConfig ) config ;
if ( ! cfg . getFile ( ) . exists ( ) ) {
return ;
}
if ( cfg . isOutdated ( ) ) {
LOG . debug ( "loading config {}" , cfg ) ; //$NON-NLS-1$
cfg . load ( ) ;
}
}
}
/ * *
/ * *
* Get the current system time
* Get the current system time
*
*