From 723cf8b2ee8302edc28e2ee8b5eead4750fd50e3 Mon Sep 17 00:00:00 2001 From: Dave Brosius Date: Sat, 17 Sep 2016 18:48:47 -0400 Subject: simplify section null checking, and guard against NPEs --- .../configuration/DefaultArchivaConfiguration.java | 67 ++++++++++++---------- 1 file changed, 36 insertions(+), 31 deletions(-) (limited to 'archiva-modules/archiva-base/archiva-configuration') 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 ); -- cgit v1.2.3