diff options
author | Dave Brosius <dbrosius@mebigfatguy.com> | 2016-09-17 18:48:47 -0400 |
---|---|---|
committer | Dave Brosius <dbrosius@mebigfatguy.com> | 2016-09-17 18:48:47 -0400 |
commit | 723cf8b2ee8302edc28e2ee8b5eead4750fd50e3 (patch) | |
tree | 57afd37cc0cca440bfa08206eff77820a5be81b3 /archiva-modules/archiva-base/archiva-configuration | |
parent | 5bc8ad7de352acb025fefb2e39967abf94163b3b (diff) | |
download | archiva-723cf8b2ee8302edc28e2ee8b5eead4750fd50e3.tar.gz archiva-723cf8b2ee8302edc28e2ee8b5eead4750fd50e3.zip |
simplify section null checking, and guard against NPEs
Diffstat (limited to 'archiva-modules/archiva-base/archiva-configuration')
-rw-r--r-- | archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java | 67 |
1 files changed, 36 insertions, 31 deletions
diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java index 665c80ab2..f37171afa 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java @@ -489,45 +489,50 @@ public class DefaultArchivaConfiguration escapeCronExpressions( configuration ); // [MRM-661] Due to a bug in the modello registry writer, we need to take these out by hand. They'll be put back by the writer. - if ( configuration.getManagedRepositories().isEmpty() && section != null ) - { - section.removeSubset( "managedRepositories" ); - } - if ( configuration.getRemoteRepositories().isEmpty() && section != null ) + if ( section != null ) { - section.removeSubset( "remoteRepositories" ); + if ( configuration.getManagedRepositories().isEmpty() ) + { + section.removeSubset( "managedRepositories" ); + } + if ( configuration.getRemoteRepositories().isEmpty() ) + { + section.removeSubset( "remoteRepositories" ); - } - if ( configuration.getProxyConnectors().isEmpty() && section != null ) - { - section.removeSubset( "proxyConnectors" ); - } - if ( configuration.getNetworkProxies().isEmpty() && section != null ) - { - section.removeSubset( "networkProxies" ); - } - if ( configuration.getLegacyArtifactPaths().isEmpty() && section != null ) - { - section.removeSubset( "legacyArtifactPaths" ); - } - if ( configuration.getRepositoryGroups().isEmpty() && section != null ) - { - section.removeSubset( "repositoryGroups" ); - } - if ( configuration.getRepositoryScanning() != null ) - { - if ( configuration.getRepositoryScanning().getKnownContentConsumers().isEmpty() && section != null ) + } + if ( configuration.getProxyConnectors().isEmpty() ) + { + section.removeSubset( "proxyConnectors" ); + } + if ( configuration.getNetworkProxies().isEmpty() ) + { + section.removeSubset( "networkProxies" ); + } + if ( configuration.getLegacyArtifactPaths().isEmpty() ) + { + section.removeSubset( "legacyArtifactPaths" ); + } + if ( configuration.getRepositoryGroups().isEmpty() ) { - section.removeSubset( "repositoryScanning.knownContentConsumers" ); + section.removeSubset( "repositoryGroups" ); } - if ( configuration.getRepositoryScanning().getInvalidContentConsumers().isEmpty() && section != null ) + if ( configuration.getRepositoryScanning() != null ) { - section.removeSubset( "repositoryScanning.invalidContentConsumers" ); + if ( configuration.getRepositoryScanning().getKnownContentConsumers().isEmpty() ) + { + section.removeSubset( "repositoryScanning.knownContentConsumers" ); + } + if ( configuration.getRepositoryScanning().getInvalidContentConsumers().isEmpty() ) + { + section.removeSubset( "repositoryScanning.invalidContentConsumers" ); + } } + + new ConfigurationRegistryWriter().write( configuration, section ); + section.save(); } - new ConfigurationRegistryWriter().write( configuration, section ); - section.save(); + this.configuration = unescapeExpressions( configuration ); |