Skip to content
Permalink
Browse files
Adding NPE checks
  • Loading branch information
effrafax committed Jul 10, 2020
1 parent 267c37a commit 2585703ad461cbab365226fae1de9b87bf24a76e
Showing 2 changed files with 18 additions and 3 deletions.
@@ -185,8 +185,14 @@ public long getInMemorySize( )
@Override
public void clear( )
{
ehcache.removeAll( );
stats.clear( );
if (ehcache!=null)
{
ehcache.removeAll( );
}
if (stats!=null)
{
stats.clear( );
}
}

@PostConstruct
@@ -39,6 +39,7 @@
import org.apache.commons.configuration2.tree.DefaultExpressionEngine;
import org.apache.commons.configuration2.tree.DefaultExpressionEngineSymbols;
import org.apache.commons.configuration2.tree.ImmutableNode;
import org.apache.commons.configuration2.tree.OverrideCombiner;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringSubstitutor;
import org.apache.commons.text.lookup.StringLookupFactory;
@@ -114,7 +115,7 @@ public CommonsConfigurationRegistry( )
{
// default constructor
logger.debug( "empty constructor" );
this.configurationBuilder = new CombinedConfigurationBuilder( );
this.configurationBuilder = new CombinedConfigurationBuilder( );
try
{
this.configuration = configurationBuilder.getConfiguration();
@@ -482,6 +483,14 @@ else if ( resource.endsWith( ".xml" ) )
}
}

public void addConfiguration(Configuration newConfiguration, String name, String prefix) {
CombinedConfiguration configuration = (CombinedConfiguration) this.configuration;
if (configuration.getConfigurationNames( ).contains( name )) {
configuration.removeConfiguration( name );
}
configuration.addConfiguration( newConfiguration, name, prefix );
}

/**
*
* Adds a new configuration source to the combined configuration.

0 comments on commit 2585703

Please sign in to comment.