Repository: maven-resolver Updated Branches: refs/heads/MRESOLVER-4 362ce50e1 -> 523f98ca6 (forced update)
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositorySystem.java ---------------------------------------------------------------------- diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositorySystem.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositorySystem.java index fbcf7c9..4269494 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositorySystem.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositorySystem.java @@ -22,6 +22,7 @@ package org.eclipse.aether.internal.impl; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import static java.util.Objects.requireNonNull; import javax.inject.Inject; import javax.inject.Named; @@ -166,111 +167,67 @@ public class DefaultRepositorySystem public DefaultRepositorySystem setVersionResolver( VersionResolver versionResolver ) { - if ( versionResolver == null ) - { - throw new IllegalArgumentException( "version resolver has not been specified" ); - } - this.versionResolver = versionResolver; + this.versionResolver = requireNonNull( versionResolver, "version resolver cannot be null" ); return this; } public DefaultRepositorySystem setVersionRangeResolver( VersionRangeResolver versionRangeResolver ) { - if ( versionRangeResolver == null ) - { - throw new IllegalArgumentException( "version range resolver has not been specified" ); - } - this.versionRangeResolver = versionRangeResolver; + this.versionRangeResolver = requireNonNull( versionRangeResolver, "version range resolver cannot be null" ); return this; } public DefaultRepositorySystem setArtifactResolver( ArtifactResolver artifactResolver ) { - if ( artifactResolver == null ) - { - throw new IllegalArgumentException( "artifact resolver has not been specified" ); - } - this.artifactResolver = artifactResolver; + this.artifactResolver = requireNonNull( artifactResolver, "artifact resolver cannot be null" ); return this; } public DefaultRepositorySystem setMetadataResolver( MetadataResolver metadataResolver ) { - if ( metadataResolver == null ) - { - throw new IllegalArgumentException( "metadata resolver has not been specified" ); - } - this.metadataResolver = metadataResolver; + this.metadataResolver = requireNonNull( metadataResolver, "metadata resolver cannot be null" ); return this; } public DefaultRepositorySystem setArtifactDescriptorReader( ArtifactDescriptorReader artifactDescriptorReader ) { - if ( artifactDescriptorReader == null ) - { - throw new IllegalArgumentException( "artifact descriptor reader has not been specified" ); - } - this.artifactDescriptorReader = artifactDescriptorReader; + this.artifactDescriptorReader = requireNonNull( artifactDescriptorReader, "artifact descriptor reader cannot be null" ); return this; } public DefaultRepositorySystem setDependencyCollector( DependencyCollector dependencyCollector ) { - if ( dependencyCollector == null ) - { - throw new IllegalArgumentException( "dependency collector has not been specified" ); - } - this.dependencyCollector = dependencyCollector; + this.dependencyCollector = requireNonNull( dependencyCollector, "dependency collector cannot be null" ); return this; } public DefaultRepositorySystem setInstaller( Installer installer ) { - if ( installer == null ) - { - throw new IllegalArgumentException( "installer has not been specified" ); - } - this.installer = installer; + this.installer = requireNonNull( installer, "installer cannot be null" ); return this; } public DefaultRepositorySystem setDeployer( Deployer deployer ) { - if ( deployer == null ) - { - throw new IllegalArgumentException( "deployer has not been specified" ); - } - this.deployer = deployer; + this.deployer = requireNonNull( deployer, "deployer cannot be null" ); return this; } public DefaultRepositorySystem setLocalRepositoryProvider( LocalRepositoryProvider localRepositoryProvider ) { - if ( localRepositoryProvider == null ) - { - throw new IllegalArgumentException( "local repository provider has not been specified" ); - } - this.localRepositoryProvider = localRepositoryProvider; + this.localRepositoryProvider = requireNonNull( localRepositoryProvider, "local repository provider cannot be null" ); return this; } public DefaultRepositorySystem setSyncContextFactory( SyncContextFactory syncContextFactory ) { - if ( syncContextFactory == null ) - { - throw new IllegalArgumentException( "sync context factory has not been specified" ); - } - this.syncContextFactory = syncContextFactory; + this.syncContextFactory = requireNonNull( syncContextFactory, "sync context factory cannot be null" ); return this; } public DefaultRepositorySystem setRemoteRepositoryManager( RemoteRepositoryManager remoteRepositoryManager ) { - if ( remoteRepositoryManager == null ) - { - throw new IllegalArgumentException( "remote repository manager has not been specified" ); - } - this.remoteRepositoryManager = remoteRepositoryManager; + this.remoteRepositoryManager = requireNonNull( remoteRepositoryManager, "remote repository provider cannot be null" ); return this; } @@ -360,7 +317,7 @@ public class DefaultRepositorySystem } else { - throw new IllegalArgumentException( "dependency node or collect request missing" ); + throw new NullPointerException( "dependency node and collect request cannot be null" ); } ArtifactRequestBuilder builder = new ArtifactRequestBuilder( trace ); @@ -469,51 +426,21 @@ public class DefaultRepositorySystem private void validateSession( RepositorySystemSession session ) { - if ( session == null ) - { - throw new IllegalArgumentException( "Invalid repository system session: the session may not be null." ); - } - if ( session.getLocalRepositoryManager() == null ) - { - invalidSession( "LocalRepositoryManager" ); - } - if ( session.getSystemProperties() == null ) - { - invalidSession( "SystemProperties" ); - } - if ( session.getUserProperties() == null ) - { - invalidSession( "UserProperties" ); - } - if ( session.getConfigProperties() == null ) - { - invalidSession( "ConfigProperties" ); - } - if ( session.getMirrorSelector() == null ) - { - invalidSession( "MirrorSelector" ); - } - if ( session.getProxySelector() == null ) - { - invalidSession( "ProxySelector" ); - } - if ( session.getAuthenticationSelector() == null ) - { - invalidSession( "AuthenticationSelector" ); - } - if ( session.getArtifactTypeRegistry() == null ) - { - invalidSession( "ArtifactTypeRegistry" ); - } - if ( session.getData() == null ) - { - invalidSession( "Data" ); - } + requireNonNull( session, "repository system session cannot be null" ); + invalidSession( session.getLocalRepositoryManager(), "local repository manager" ); + invalidSession( session.getSystemProperties(), "system properties" ); + invalidSession( session.getUserProperties(), "user properties" ); + invalidSession( session.getConfigProperties(), "config properties" ); + invalidSession( session.getMirrorSelector(), "mirror selector" ); + invalidSession( session.getProxySelector(), "proxy selector" ); + invalidSession( session.getAuthenticationSelector(), "authentication selector" ); + invalidSession( session.getArtifactTypeRegistry(), "artifact type registry" ); + invalidSession( session.getData(), "data" ); } - private void invalidSession( String name ) + private void invalidSession( Object obj, String name ) { - throw new IllegalArgumentException( "Invalid repository system session: " + name + " is not set." ); + requireNonNull( obj, "repository system session's " + name + " cannot be null" ); } } http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultTransporterProvider.java ---------------------------------------------------------------------- diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultTransporterProvider.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultTransporterProvider.java index 133fd81..7779a6f 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultTransporterProvider.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultTransporterProvider.java @@ -22,6 +22,7 @@ package org.eclipse.aether.internal.impl; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import static java.util.Objects.requireNonNull; import java.util.Set; import javax.inject.Inject; @@ -76,11 +77,7 @@ public final class DefaultTransporterProvider public DefaultTransporterProvider addTransporterFactory( TransporterFactory factory ) { - if ( factory == null ) - { - throw new IllegalArgumentException( "transporter factory has not been specified" ); - } - factories.add( factory ); + factories.add( requireNonNull( factory, "transporter factory cannot be null" ) ); return this; } @@ -100,10 +97,7 @@ public final class DefaultTransporterProvider public Transporter newTransporter( RepositorySystemSession session, RemoteRepository repository ) throws NoTransporterException { - if ( repository == null ) - { - throw new IllegalArgumentException( "remote repository has not been specified" ); - } + requireNonNull( repository, "remote repository cannot be null" ); PrioritizedComponents<TransporterFactory> factories = new PrioritizedComponents<TransporterFactory>( session ); for ( TransporterFactory factory : this.factories ) http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultUpdateCheckManager.java ---------------------------------------------------------------------- diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultUpdateCheckManager.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultUpdateCheckManager.java index eb4eff9..07dfb9e 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultUpdateCheckManager.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultUpdateCheckManager.java @@ -23,6 +23,7 @@ import java.io.File; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import static java.util.Objects.requireNonNull; import java.util.Properties; import java.util.Set; import java.util.TreeSet; @@ -106,11 +107,7 @@ public class DefaultUpdateCheckManager public DefaultUpdateCheckManager setUpdatePolicyAnalyzer( UpdatePolicyAnalyzer updatePolicyAnalyzer ) { - if ( updatePolicyAnalyzer == null ) - { - throw new IllegalArgumentException( "update policy analyzer has not been specified" ); - } - this.updatePolicyAnalyzer = updatePolicyAnalyzer; + this.updatePolicyAnalyzer = requireNonNull( updatePolicyAnalyzer, "update policy analyzer cannot be null" ); return this; } @@ -132,11 +129,7 @@ public class DefaultUpdateCheckManager Artifact artifact = check.getItem(); RemoteRepository repository = check.getRepository(); - File artifactFile = check.getFile(); - if ( artifactFile == null ) - { - throw new IllegalArgumentException( String.format( "The artifact '%s' has no file attached", artifact ) ); - } + File artifactFile = requireNonNull( check.getFile(), String.format( "The artifact '%s' has no file attached", artifact ) ); boolean fileExists = check.isFileValid() && artifactFile.exists(); @@ -269,11 +262,7 @@ public class DefaultUpdateCheckManager Metadata metadata = check.getItem(); RemoteRepository repository = check.getRepository(); - File metadataFile = check.getFile(); - if ( metadataFile == null ) - { - throw new IllegalArgumentException( String.format( "The metadata '%s' has no file attached", metadata ) ); - } + File metadataFile = requireNonNull( check.getFile(), String.format( "The metadata '%s' has no file attached", metadata ) ); boolean fileExists = check.isFileValid() && metadataFile.exists(); http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManager.java ---------------------------------------------------------------------- diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManager.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManager.java index 11ba9a1..327ec3d 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManager.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManager.java @@ -25,6 +25,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import static java.util.Objects.requireNonNull; import java.util.Properties; import org.eclipse.aether.RepositorySystemSession; @@ -165,11 +166,7 @@ class EnhancedLocalRepositoryManager private void addArtifact( Artifact artifact, Collection<String> repositories, boolean local ) { - if ( artifact == null ) - { - throw new IllegalArgumentException( "artifact to register not specified" ); - } - String path = getPathForArtifact( artifact, local ); + String path = getPathForArtifact( requireNonNull( artifact, "artifact cannot be null" ), local ); File file = new File( getRepository().getBasedir(), path ); addRepo( file, repositories ); } http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleLocalRepositoryManager.java ---------------------------------------------------------------------- diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleLocalRepositoryManager.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleLocalRepositoryManager.java index 97c7bba..7d97233 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleLocalRepositoryManager.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/SimpleLocalRepositoryManager.java @@ -20,6 +20,7 @@ package org.eclipse.aether.internal.impl; */ import java.io.File; +import static java.util.Objects.requireNonNull; import java.util.SortedSet; import java.util.TreeSet; @@ -58,10 +59,7 @@ class SimpleLocalRepositoryManager SimpleLocalRepositoryManager( File basedir, String type ) { - if ( basedir == null ) - { - throw new IllegalArgumentException( "base directory has not been specified" ); - } + requireNonNull( basedir, "base directory cannot be null" ); repository = new LocalRepository( basedir.getAbsoluteFile(), type ); } http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultDependencyCollectorTest.java ---------------------------------------------------------------------- diff --git a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultDependencyCollectorTest.java b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultDependencyCollectorTest.java index b78838a..72c4602 100644 --- a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultDependencyCollectorTest.java +++ b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultDependencyCollectorTest.java @@ -164,11 +164,11 @@ public class DefaultDependencyCollectorTest } catch ( IndexOutOfBoundsException e ) { - throw new IllegalArgumentException( "Illegal coordinates for child", e ); + throw new IllegalArgumentException( "illegal coordinates for child", e ); } catch ( NullPointerException e ) { - throw new IllegalArgumentException( "Illegal coordinates for child", e ); + throw new IllegalArgumentException( "illegal coordinates for child", e ); } } http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultUpdateCheckManagerTest.java ---------------------------------------------------------------------- diff --git a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultUpdateCheckManagerTest.java b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultUpdateCheckManagerTest.java index 43ccd54..8686ee8 100644 --- a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultUpdateCheckManagerTest.java +++ b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultUpdateCheckManagerTest.java @@ -467,7 +467,7 @@ public class DefaultUpdateCheckManagerTest assertEquals( false, check.isRequired() ); } - @Test( expected = IllegalArgumentException.class ) + @Test( expected = NullPointerException.class ) public void testCheckArtifactFailOnNoFile() throws Exception { http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/layout/RepositoryLayout.java ---------------------------------------------------------------------- diff --git a/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/layout/RepositoryLayout.java b/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/layout/RepositoryLayout.java index 7ae69ac..a36c542 100644 --- a/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/layout/RepositoryLayout.java +++ b/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/layout/RepositoryLayout.java @@ -22,6 +22,7 @@ package org.eclipse.aether.spi.connector.layout; import java.net.URI; import java.util.List; import java.util.Locale; +import static java.util.Objects.requireNonNull; import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.metadata.Metadata; @@ -88,14 +89,12 @@ public interface RepositoryLayout private static void verify( String algorithm, URI location ) { - if ( algorithm == null || algorithm.length() <= 0 ) + requireNonNull( algorithm, "checksum algorithm cannot be null" ); + if ( algorithm.length() == 0 ) { - throw new IllegalArgumentException( "checksum algorithm has not been specified" ); - } - if ( location == null ) - { - throw new IllegalArgumentException( "checksum location has not been specified" ); + throw new IllegalArgumentException( "checksum algorithm cannot be empty" ); } + requireNonNull( location, "checksum location cannot be null" ); if ( location.isAbsolute() ) { throw new IllegalArgumentException( "checksum location must be relative" ); http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/transport/TransportTask.java ---------------------------------------------------------------------- diff --git a/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/transport/TransportTask.java b/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/transport/TransportTask.java index f74b301..05525b1 100644 --- a/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/transport/TransportTask.java +++ b/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/transport/TransportTask.java @@ -20,10 +20,11 @@ package org.eclipse.aether.spi.connector.transport; */ import java.net.URI; +import static java.util.Objects.requireNonNull; /** * A transport task. - * + * * @noextend This class is not intended to be extended by clients. */ public abstract class TransportTask @@ -56,17 +57,13 @@ public abstract class TransportTask TransportTask setLocation( URI location ) { - if ( location == null ) - { - throw new IllegalArgumentException( "resource location has not been specified" ); - } - this.location = location; + this.location = requireNonNull( location, "location type cannot be null" ); return this; } /** * Gets the listener that is to be notified during the transfer. - * + * * @return The listener to notify of progress, never {@code null}. */ public TransportListener getListener() http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/DependencyGraphParser.java ---------------------------------------------------------------------- diff --git a/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/DependencyGraphParser.java b/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/DependencyGraphParser.java index d6f7a17..9a9a284 100644 --- a/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/DependencyGraphParser.java +++ b/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/DependencyGraphParser.java @@ -246,7 +246,7 @@ public class DependencyGraphParser { if ( !substitutionIterator.hasNext() ) { - throw new IllegalArgumentException( "not enough substitutions to fill placeholders" ); + throw new IllegalStateException( "not enough substitutions to fill placeholders" ); } line = line.replaceFirst( "%s", substitutionIterator.next() ); } http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestDependencyGraphTransformationContext.java ---------------------------------------------------------------------- diff --git a/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestDependencyGraphTransformationContext.java b/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestDependencyGraphTransformationContext.java index c3da4d9..d1fcdbc 100644 --- a/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestDependencyGraphTransformationContext.java +++ b/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestDependencyGraphTransformationContext.java @@ -21,6 +21,7 @@ package org.eclipse.aether.internal.test.util; import java.util.HashMap; import java.util.Map; +import static java.util.Objects.requireNonNull; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.collection.DependencyGraphTransformationContext; @@ -48,19 +49,12 @@ class TestDependencyGraphTransformationContext public Object get( Object key ) { - if ( key == null ) - { - throw new IllegalArgumentException( "key must not be null" ); - } - return map.get( key ); + return map.get( requireNonNull( key, "key cannot be null" ) ); } public Object put( Object key, Object value ) { - if ( key == null ) - { - throw new IllegalArgumentException( "key must not be null" ); - } + requireNonNull( key, "key cannot be null" ); if ( value != null ) { return map.put( key, value ); http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestVersionConstraint.java ---------------------------------------------------------------------- diff --git a/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestVersionConstraint.java b/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestVersionConstraint.java index bd84687..51228ee 100644 --- a/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestVersionConstraint.java +++ b/maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestVersionConstraint.java @@ -19,6 +19,8 @@ package org.eclipse.aether.internal.test.util; * under the License. */ +import static java.util.Objects.requireNonNull; + import org.eclipse.aether.version.Version; import org.eclipse.aether.version.VersionConstraint; import org.eclipse.aether.version.VersionRange; @@ -36,31 +38,23 @@ final class TestVersionConstraint /** * Creates a version constraint from the specified version range. - * + * * @param range The version range, must not be {@code null}. */ public TestVersionConstraint( VersionRange range ) { - if ( range == null ) - { - throw new IllegalArgumentException( "version range missing" ); - } - this.range = range; + this.range = requireNonNull( range, "version range cannot be null" ); this.version = null; } /** * Creates a version constraint from the specified version. - * + * * @param version The version, must not be {@code null}. */ public TestVersionConstraint( Version version ) { - if ( version == null ) - { - throw new IllegalArgumentException( "version missing" ); - } - this.version = version; + this.version = requireNonNull( version, "version cannot be null" ); this.range = null; } http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/internal/transport/wagon/PlexusWagonConfigurator.java ---------------------------------------------------------------------- diff --git a/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/internal/transport/wagon/PlexusWagonConfigurator.java b/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/internal/transport/wagon/PlexusWagonConfigurator.java index 808d2b7..df2b2c3 100644 --- a/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/internal/transport/wagon/PlexusWagonConfigurator.java +++ b/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/internal/transport/wagon/PlexusWagonConfigurator.java @@ -19,6 +19,8 @@ package org.eclipse.aether.internal.transport.wagon; * under the License. */ +import static java.util.Objects.requireNonNull; + import org.apache.maven.wagon.Wagon; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.classworlds.realm.ClassRealm; @@ -58,16 +60,12 @@ public class PlexusWagonConfigurator /** * Creates a wagon configurator using the specified Plexus container. - * + * * @param container The Plexus container instance to use, must not be {@code null}. */ public PlexusWagonConfigurator( PlexusContainer container ) { - if ( container == null ) - { - throw new IllegalArgumentException( "plexus container has not been specified" ); - } - this.container = container; + this.container = requireNonNull( container, "plexus container cannot be null" ); } public void configure( Wagon wagon, Object configuration ) http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/internal/transport/wagon/PlexusWagonProvider.java ---------------------------------------------------------------------- diff --git a/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/internal/transport/wagon/PlexusWagonProvider.java b/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/internal/transport/wagon/PlexusWagonProvider.java index 6f40f0d..d534695 100644 --- a/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/internal/transport/wagon/PlexusWagonProvider.java +++ b/maven-resolver-transport-wagon/src/main/java/org/eclipse/aether/internal/transport/wagon/PlexusWagonProvider.java @@ -19,6 +19,8 @@ package org.eclipse.aether.internal.transport.wagon; * under the License. */ +import static java.util.Objects.requireNonNull; + import org.apache.maven.wagon.Wagon; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.annotations.Component; @@ -49,16 +51,12 @@ public class PlexusWagonProvider /** * Creates a wagon provider using the specified Plexus container. - * + * * @param container The Plexus container instance to use, must not be {@code null}. */ public PlexusWagonProvider( PlexusContainer container ) { - if ( container == null ) - { - throw new IllegalArgumentException( "plexus container has not been specified" ); - } - this.container = container; + this.container = requireNonNull( container, "plexus container cannot be null" ); } public Wagon lookup( String roleHint ) http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/DelegatingArtifact.java ---------------------------------------------------------------------- diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/DelegatingArtifact.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/DelegatingArtifact.java index 8816ae5..00fbcd4 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/DelegatingArtifact.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/DelegatingArtifact.java @@ -21,6 +21,7 @@ package org.eclipse.aether.util.artifact; import java.io.File; import java.util.Map; +import static java.util.Objects.requireNonNull; import org.eclipse.aether.artifact.AbstractArtifact; import org.eclipse.aether.artifact.Artifact; @@ -37,22 +38,18 @@ public abstract class DelegatingArtifact /** * Creates a new artifact instance that delegates to the specified artifact. - * + * * @param delegate The artifact to delegate to, must not be {@code null}. */ protected DelegatingArtifact( Artifact delegate ) { - if ( delegate == null ) - { - throw new IllegalArgumentException( "delegate artifact not specified" ); - } - this.delegate = delegate; + this.delegate = requireNonNull( delegate, "delegate artifact cannot be null" ); } /** * Creates a new artifact instance that delegates to the specified artifact. Subclasses should use this hook to * instantiate themselves, taking along any data from the current instance that was added. - * + * * @param delegate The artifact to delegate to, must not be {@code null}. * @return The new delegating artifact, never {@code null}. */ http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/SubArtifact.java ---------------------------------------------------------------------- diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/SubArtifact.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/SubArtifact.java index ed4d55b..e0beb21 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/SubArtifact.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/SubArtifact.java @@ -21,6 +21,7 @@ package org.eclipse.aether.util.artifact; import java.io.File; import java.util.Map; +import static java.util.Objects.requireNonNull; import org.eclipse.aether.artifact.AbstractArtifact; import org.eclipse.aether.artifact.Artifact; @@ -105,11 +106,7 @@ public final class SubArtifact public SubArtifact( Artifact mainArtifact, String classifier, String extension, Map<String, String> properties, File file ) { - if ( mainArtifact == null ) - { - throw new IllegalArgumentException( "no artifact specified" ); - } - this.mainArtifact = mainArtifact; + this.mainArtifact = requireNonNull( mainArtifact, "main artifact cannot be null" ); this.classifier = classifier; this.extension = extension; this.file = file; http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-util/src/main/java/org/eclipse/aether/util/concurrency/RunnableErrorForwarder.java ---------------------------------------------------------------------- diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/concurrency/RunnableErrorForwarder.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/concurrency/RunnableErrorForwarder.java index 270ea82..6bb2f9d 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/concurrency/RunnableErrorForwarder.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/concurrency/RunnableErrorForwarder.java @@ -19,6 +19,8 @@ package org.eclipse.aether.util.concurrency; * under the License. */ +import static java.util.Objects.requireNonNull; + import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.locks.LockSupport; @@ -54,16 +56,13 @@ public final class RunnableErrorForwarder /** * Wraps the specified runnable into an equivalent runnable that will allow forwarding of uncaught errors. - * + * * @param runnable The runnable from which to forward errors, must not be {@code null}. * @return The error-forwarding runnable to eventually execute, never {@code null}. */ public Runnable wrap( final Runnable runnable ) { - if ( runnable == null ) - { - throw new IllegalArgumentException( "runnable missing" ); - } + requireNonNull( runnable, "runnable cannot be null" ); counter.incrementAndGet(); http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-util/src/main/java/org/eclipse/aether/util/filter/NotDependencyFilter.java ---------------------------------------------------------------------- diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/filter/NotDependencyFilter.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/filter/NotDependencyFilter.java index d5fdb24..dcb419a 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/filter/NotDependencyFilter.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/filter/NotDependencyFilter.java @@ -20,6 +20,7 @@ package org.eclipse.aether.util.filter; */ import java.util.List; +import static java.util.Objects.requireNonNull; import org.eclipse.aether.graph.DependencyFilter; import org.eclipse.aether.graph.DependencyNode; @@ -35,16 +36,12 @@ public final class NotDependencyFilter /** * Creates a new filter negatint the specified filter. - * + * * @param filter The filter to negate, must not be {@code null}. */ public NotDependencyFilter( DependencyFilter filter ) { - if ( filter == null ) - { - throw new IllegalArgumentException( "no filter specified" ); - } - this.filter = filter; + this.filter = requireNonNull( filter, "dependency filter cannot be null" ); } public boolean accept( DependencyNode node, List<DependencyNode> parents ) http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/transformer/ConflictResolver.java ---------------------------------------------------------------------- diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/transformer/ConflictResolver.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/transformer/ConflictResolver.java index 6ccc508..7da2e48 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/transformer/ConflictResolver.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/transformer/ConflictResolver.java @@ -30,6 +30,7 @@ import java.util.Iterator; import java.util.List; import java.util.ListIterator; import java.util.Map; +import static java.util.Objects.requireNonNull; import org.eclipse.aether.RepositoryException; import org.eclipse.aether.RepositorySystemSession; @@ -108,26 +109,10 @@ public final class ConflictResolver public ConflictResolver( VersionSelector versionSelector, ScopeSelector scopeSelector, OptionalitySelector optionalitySelector, ScopeDeriver scopeDeriver ) { - if ( versionSelector == null ) - { - throw new IllegalArgumentException( "version selector not specified" ); - } - this.versionSelector = versionSelector; - if ( scopeSelector == null ) - { - throw new IllegalArgumentException( "scope selector not specified" ); - } - this.scopeSelector = scopeSelector; - if ( scopeDeriver == null ) - { - throw new IllegalArgumentException( "scope deriver not specified" ); - } - this.scopeDeriver = scopeDeriver; - if ( optionalitySelector == null ) - { - throw new IllegalArgumentException( "optionality selector not specified" ); - } - this.optionalitySelector = optionalitySelector; + this.versionSelector = requireNonNull( versionSelector, "version selector cannot be null" ); + this.scopeSelector = requireNonNull( scopeSelector, "scope selector cannot be null" ); + this.optionalitySelector = requireNonNull( optionalitySelector, "optionality selector cannot be null" ); + this.scopeDeriver = requireNonNull( scopeDeriver, "scope deriver cannot be null" ); } public DependencyNode transformGraph( DependencyNode node, DependencyGraphTransformationContext context ) http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/visitor/FilteringDependencyVisitor.java ---------------------------------------------------------------------- diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/visitor/FilteringDependencyVisitor.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/visitor/FilteringDependencyVisitor.java index 49f779c..a126bb7 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/visitor/FilteringDependencyVisitor.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/visitor/FilteringDependencyVisitor.java @@ -19,6 +19,8 @@ package org.eclipse.aether.util.graph.visitor; * under the License. */ +import static java.util.Objects.requireNonNull; + import org.eclipse.aether.graph.DependencyFilter; import org.eclipse.aether.graph.DependencyNode; import org.eclipse.aether.graph.DependencyVisitor; @@ -41,17 +43,13 @@ public final class FilteringDependencyVisitor /** * Creates a new visitor that delegates traversal of nodes matching the given filter to the specified visitor. - * + * * @param visitor The visitor to delegate to, must not be {@code null}. * @param filter The filter to apply, may be {@code null} to not filter. */ public FilteringDependencyVisitor( DependencyVisitor visitor, DependencyFilter filter ) { - if ( visitor == null ) - { - throw new IllegalArgumentException( "dependency visitor not specified" ); - } - this.visitor = visitor; + this.visitor = requireNonNull( visitor, "dependency visitor delegate cannot be null" ); this.filter = filter; this.accepts = new Stack<Boolean>(); this.parents = new Stack<DependencyNode>(); http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/visitor/TreeDependencyVisitor.java ---------------------------------------------------------------------- diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/visitor/TreeDependencyVisitor.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/visitor/TreeDependencyVisitor.java index f1658a8..2f9012d 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/visitor/TreeDependencyVisitor.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/visitor/TreeDependencyVisitor.java @@ -21,6 +21,7 @@ package org.eclipse.aether.util.graph.visitor; import java.util.IdentityHashMap; import java.util.Map; +import static java.util.Objects.requireNonNull; import org.eclipse.aether.graph.DependencyNode; import org.eclipse.aether.graph.DependencyVisitor; @@ -42,16 +43,12 @@ public final class TreeDependencyVisitor /** * Creates a new visitor that delegates to the specified visitor. - * + * * @param visitor The visitor to delegate to, must not be {@code null}. */ public TreeDependencyVisitor( DependencyVisitor visitor ) { - if ( visitor == null ) - { - throw new IllegalArgumentException( "no visitor delegate specified" ); - } - this.visitor = visitor; + this.visitor = requireNonNull( visitor, "dependency visitor delegate cannot be null" ); visitedNodes = new IdentityHashMap<DependencyNode, Object>( 512 ); visits = new Stack<Boolean>(); } http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/ComponentAuthentication.java ---------------------------------------------------------------------- diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/ComponentAuthentication.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/ComponentAuthentication.java index af83c9d..c9c206a 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/ComponentAuthentication.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/ComponentAuthentication.java @@ -20,6 +20,7 @@ package org.eclipse.aether.util.repository; */ import java.util.Map; +import static java.util.Objects.requireNonNull; import org.eclipse.aether.repository.Authentication; import org.eclipse.aether.repository.AuthenticationContext; @@ -39,11 +40,11 @@ final class ComponentAuthentication public ComponentAuthentication( String key, Object value ) { - if ( key == null ) + this.key = requireNonNull( key, "authentication key cannot be null" ); + if ( key.length() == 0 ) { - throw new IllegalArgumentException( "authentication key missing" ); + throw new IllegalArgumentException( "authentication key cannot be empty" ); } - this.key = key; this.value = value; } http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/ConservativeAuthenticationSelector.java ---------------------------------------------------------------------- diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/ConservativeAuthenticationSelector.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/ConservativeAuthenticationSelector.java index 6e727e5..f1e22f2 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/ConservativeAuthenticationSelector.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/ConservativeAuthenticationSelector.java @@ -19,6 +19,8 @@ package org.eclipse.aether.util.repository; * under the License. */ +import static java.util.Objects.requireNonNull; + import org.eclipse.aether.repository.Authentication; import org.eclipse.aether.repository.AuthenticationSelector; import org.eclipse.aether.repository.RemoteRepository; @@ -35,17 +37,13 @@ public final class ConservativeAuthenticationSelector /** * Creates a new selector that delegates to the specified selector. - * + * * @param selector The selector to delegate to in case a repository has no authentication yet, must not be * {@code null}. */ public ConservativeAuthenticationSelector( AuthenticationSelector selector ) { - if ( selector == null ) - { - throw new IllegalArgumentException( "no authentication selector specified" ); - } - this.selector = selector; + this.selector = requireNonNull( selector, "authentication selector cannot be null" ); } public Authentication getAuthentication( RemoteRepository repository ) http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/ConservativeProxySelector.java ---------------------------------------------------------------------- diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/ConservativeProxySelector.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/ConservativeProxySelector.java index 437c719..c71fe13 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/ConservativeProxySelector.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/ConservativeProxySelector.java @@ -19,6 +19,8 @@ package org.eclipse.aether.util.repository; * under the License. */ +import static java.util.Objects.requireNonNull; + import org.eclipse.aether.repository.Proxy; import org.eclipse.aether.repository.ProxySelector; import org.eclipse.aether.repository.RemoteRepository; @@ -35,16 +37,12 @@ public final class ConservativeProxySelector /** * Creates a new selector that delegates to the specified selector. - * + * * @param selector The selector to delegate to in case a repository has no proxy yet, must not be {@code null}. */ public ConservativeProxySelector( ProxySelector selector ) { - if ( selector == null ) - { - throw new IllegalArgumentException( "no proxy selector specified" ); - } - this.selector = selector; + this.selector = requireNonNull( selector, "proxy selector cannot be null" ); } public Proxy getProxy( RemoteRepository repository ) http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/DefaultProxySelector.java ---------------------------------------------------------------------- diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/DefaultProxySelector.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/DefaultProxySelector.java index 3977c6c..429fd34 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/DefaultProxySelector.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/DefaultProxySelector.java @@ -20,10 +20,12 @@ package org.eclipse.aether.util.repository; */ import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; +import static java.util.Objects.requireNonNull; import java.util.StringTokenizer; import java.util.regex.Pattern; @@ -50,10 +52,7 @@ public final class DefaultProxySelector */ public DefaultProxySelector add( Proxy proxy, String nonProxyHosts ) { - if ( proxy == null ) - { - throw new IllegalArgumentException( "proxy not specified" ); - } + requireNonNull( proxy, "proxy cannot be null" ); proxies.add( new ProxyDef( proxy, nonProxyHosts ) ); return this; http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/SecretAuthentication.java ---------------------------------------------------------------------- diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/SecretAuthentication.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/SecretAuthentication.java index 8b3b095..445d76c 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/SecretAuthentication.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/SecretAuthentication.java @@ -21,6 +21,7 @@ package org.eclipse.aether.util.repository; import java.util.Arrays; import java.util.Map; +import static java.util.Objects.requireNonNull; import org.eclipse.aether.repository.Authentication; import org.eclipse.aether.repository.AuthenticationContext; @@ -64,11 +65,11 @@ final class SecretAuthentication private SecretAuthentication( char[] value, String key ) { - if ( key == null ) + this.key = requireNonNull( key, "authentication key cannot be null" ); + if ( key.length() == 0 ) { - throw new IllegalArgumentException( "authentication key missing" ); + throw new IllegalArgumentException( "authentication key cannot be empty" ); } - this.key = key; this.secretHash = Arrays.hashCode( value ) ^ KEYS[0].hashCode(); this.value = xor( value ); } http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/StringAuthentication.java ---------------------------------------------------------------------- diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/StringAuthentication.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/StringAuthentication.java index 8438082..606d8f2 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/StringAuthentication.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/StringAuthentication.java @@ -20,6 +20,7 @@ package org.eclipse.aether.util.repository; */ import java.util.Map; +import static java.util.Objects.requireNonNull; import org.eclipse.aether.repository.Authentication; import org.eclipse.aether.repository.AuthenticationContext; @@ -38,11 +39,11 @@ final class StringAuthentication public StringAuthentication( String key, String value ) { - if ( key == null ) + this.key = requireNonNull( key, "authentication key cannot be null" ); + if ( key.length() == 0 ) { - throw new IllegalArgumentException( "authentication key missing" ); + throw new IllegalArgumentException( "authentication key cannot be empty" ); } - this.key = key; this.value = value; } http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-util/src/main/java/org/eclipse/aether/util/version/GenericVersionConstraint.java ---------------------------------------------------------------------- diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/version/GenericVersionConstraint.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/version/GenericVersionConstraint.java index bfcd455..27c52fa 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/version/GenericVersionConstraint.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/version/GenericVersionConstraint.java @@ -19,6 +19,8 @@ package org.eclipse.aether.util.version; * under the License. */ +import static java.util.Objects.requireNonNull; + import org.eclipse.aether.version.Version; import org.eclipse.aether.version.VersionConstraint; import org.eclipse.aether.version.VersionRange; @@ -36,31 +38,23 @@ final class GenericVersionConstraint /** * Creates a version constraint from the specified version range. - * + * * @param range The version range, must not be {@code null}. */ public GenericVersionConstraint( VersionRange range ) { - if ( range == null ) - { - throw new IllegalArgumentException( "version range missing" ); - } - this.range = range; + this.range = requireNonNull( range, "version range cannot be null" ); this.version = null; } /** * Creates a version constraint from the specified version. - * + * * @param version The version, must not be {@code null}. */ public GenericVersionConstraint( Version version ) { - if ( version == null ) - { - throw new IllegalArgumentException( "version missing" ); - } - this.version = version; + this.version = requireNonNull( version, "version cannot be null" ); this.range = null; } http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-util/src/test/java/org/eclipse/aether/util/artifact/SubArtifactTest.java ---------------------------------------------------------------------- diff --git a/maven-resolver-util/src/test/java/org/eclipse/aether/util/artifact/SubArtifactTest.java b/maven-resolver-util/src/test/java/org/eclipse/aether/util/artifact/SubArtifactTest.java index dc0e472..0ae333e 100644 --- a/maven-resolver-util/src/test/java/org/eclipse/aether/util/artifact/SubArtifactTest.java +++ b/maven-resolver-util/src/test/java/org/eclipse/aether/util/artifact/SubArtifactTest.java @@ -60,7 +60,7 @@ public class SubArtifactTest assertSame( null, a.getProperty( "key", null ) ); } - @Test( expected = IllegalArgumentException.class ) + @Test( expected = NullPointerException.class ) public void testMainArtifactMissing() { new SubArtifact( null, "", "pom" ); http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/523f98ca/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/transformer/JavaScopeSelectorTest.java ---------------------------------------------------------------------- diff --git a/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/transformer/JavaScopeSelectorTest.java b/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/transformer/JavaScopeSelectorTest.java index 2737803..09f9c33 100644 --- a/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/transformer/JavaScopeSelectorTest.java +++ b/maven-resolver-util/src/test/java/org/eclipse/aether/util/graph/transformer/JavaScopeSelectorTest.java @@ -76,11 +76,11 @@ public class JavaScopeSelectorTest } catch ( IndexOutOfBoundsException e ) { - throw new IllegalArgumentException( "Illegal coordinates for child", e ); + throw new IllegalArgumentException( "illegal coordinates for child", e ); } catch ( NullPointerException e ) { - throw new IllegalArgumentException( "Illegal coordinates for child", e ); + throw new IllegalArgumentException( "illegal coordinates for child", e ); } }