[MRESOLVER-4] Use java.util.Objects#requireNonNull to intercept invalid input
Project: http://git-wip-us.apache.org/repos/asf/maven-resolver/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-resolver/commit/f4a0ce15 Tree: http://git-wip-us.apache.org/repos/asf/maven-resolver/tree/f4a0ce15 Diff: http://git-wip-us.apache.org/repos/asf/maven-resolver/diff/f4a0ce15 Branch: refs/heads/master Commit: f4a0ce151c3c3d7962e368567e4d7a1bffefcca4 Parents: 03d5748 Author: Michael Osipov <micha...@apache.org> Authored: Mon Nov 7 22:06:19 2016 +0100 Committer: Michael Osipov <micha...@apache.org> Committed: Mon Nov 7 22:06:19 2016 +0100 ---------------------------------------------------------------------- .../aether/DefaultRepositorySystemSession.java | 8 +- .../org/eclipse/aether/DefaultSessionData.java | 17 +-- .../org/eclipse/aether/RepositoryEvent.java | 17 +-- .../aether/artifact/DefaultArtifactType.java | 13 +- .../aether/collection/CollectResult.java | 11 +- .../eclipse/aether/deployment/DeployResult.java | 11 +- .../aether/graph/DefaultDependencyNode.java | 6 +- .../org/eclipse/aether/graph/Dependency.java | 7 +- .../aether/installation/InstallResult.java | 11 +- .../aether/metadata/DefaultMetadata.java | 7 +- .../repository/AuthenticationContext.java | 21 ++-- .../aether/repository/LocalArtifactResult.java | 13 +- .../aether/repository/LocalMetadataResult.java | 13 +- .../aether/repository/RemoteRepository.java | 11 +- .../resolution/ArtifactDescriptorResult.java | 9 +- .../aether/resolution/ArtifactResult.java | 11 +- .../aether/resolution/DependencyResult.java | 9 +- .../aether/resolution/MetadataResult.java | 12 +- .../aether/resolution/VersionRangeResult.java | 9 +- .../aether/resolution/VersionResult.java | 11 +- .../eclipse/aether/transfer/TransferEvent.java | 41 ++----- .../eclipse/aether/version/VersionRange.java | 12 +- .../repository/RemoteRepositoryBuilderTest.java | 2 +- .../basic/BasicRepositoryConnector.java | 13 +- .../basic/BasicRepositoryConnectorFactory.java | 34 ++---- .../aether/impl/DefaultServiceLocator.java | 25 +--- .../internal/impl/DefaultArtifactResolver.java | 49 ++------ .../impl/DefaultDependencyCollector.java | 19 +-- ...ultDependencyGraphTransformationContext.java | 12 +- .../aether/internal/impl/DefaultDeployer.java | 49 ++------ .../aether/internal/impl/DefaultInstaller.java | 25 +--- .../impl/DefaultLocalRepositoryProvider.java | 7 +- .../internal/impl/DefaultMetadataResolver.java | 37 ++---- .../impl/DefaultRemoteRepositoryManager.java | 13 +- .../DefaultRepositoryConnectorProvider.java | 12 +- .../impl/DefaultRepositoryEventDispatcher.java | 7 +- .../impl/DefaultRepositoryLayoutProvider.java | 12 +- .../internal/impl/DefaultRepositorySystem.java | 121 ++++--------------- .../impl/DefaultTransporterProvider.java | 12 +- .../impl/DefaultUpdateCheckManager.java | 19 +-- .../impl/EnhancedLocalRepositoryManager.java | 7 +- .../impl/SimpleLocalRepositoryManager.java | 6 +- .../impl/DefaultDependencyCollectorTest.java | 4 +- .../impl/DefaultUpdateCheckManagerTest.java | 2 +- .../spi/connector/layout/RepositoryLayout.java | 11 +- .../spi/connector/transport/TransportTask.java | 11 +- .../test/util/DependencyGraphParser.java | 2 +- ...estDependencyGraphTransformationContext.java | 12 +- .../test/util/TestVersionConstraint.java | 18 +-- .../wagon/PlexusWagonConfigurator.java | 10 +- .../transport/wagon/PlexusWagonProvider.java | 10 +- .../util/artifact/DelegatingArtifact.java | 11 +- .../aether/util/artifact/SubArtifact.java | 7 +- .../concurrency/RunnableErrorForwarder.java | 9 +- .../aether/util/filter/NotDependencyFilter.java | 9 +- .../graph/transformer/ConflictResolver.java | 25 +--- .../visitor/FilteringDependencyVisitor.java | 10 +- .../graph/visitor/TreeDependencyVisitor.java | 9 +- .../repository/ComponentAuthentication.java | 7 +- .../ConservativeAuthenticationSelector.java | 10 +- .../repository/ConservativeProxySelector.java | 10 +- .../util/repository/DefaultProxySelector.java | 7 +- .../util/repository/SecretAuthentication.java | 7 +- .../util/repository/StringAuthentication.java | 7 +- .../util/version/GenericVersionConstraint.java | 18 +-- .../aether/util/artifact/SubArtifactTest.java | 2 +- .../transformer/JavaScopeSelectorTest.java | 4 +- 67 files changed, 290 insertions(+), 703 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-api/src/main/java/org/eclipse/aether/DefaultRepositorySystemSession.java ---------------------------------------------------------------------- diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/DefaultRepositorySystemSession.java b/maven-resolver-api/src/main/java/org/eclipse/aether/DefaultRepositorySystemSession.java index 93ebaca..fc529d6 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/DefaultRepositorySystemSession.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/DefaultRepositorySystemSession.java @@ -22,6 +22,7 @@ package org.eclipse.aether; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import org.eclipse.aether.artifact.ArtifactType; import org.eclipse.aether.artifact.ArtifactTypeRegistry; @@ -137,15 +138,12 @@ public final class DefaultRepositorySystemSession * system/user/config properties are copied as well. In other words, invoking any mutator on the new session itself * has no effect on the original session. Other mutable objects like the session data and cache (if any) are not * copied and will be shared with the original session unless reconfigured. - * + * * @param session The session to copy, must not be {@code null}. */ public DefaultRepositorySystemSession( RepositorySystemSession session ) { - if ( session == null ) - { - throw new IllegalArgumentException( "repository system session not specified" ); - } + Objects.requireNonNull( session, "repository system session cannot be null" ); setOffline( session.isOffline() ); setIgnoreArtifactDescriptorRepositories( session.isIgnoreArtifactDescriptorRepositories() ); http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-api/src/main/java/org/eclipse/aether/DefaultSessionData.java ---------------------------------------------------------------------- diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/DefaultSessionData.java b/maven-resolver-api/src/main/java/org/eclipse/aether/DefaultSessionData.java index e78df3a..4e44166 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/DefaultSessionData.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/DefaultSessionData.java @@ -1,5 +1,7 @@ package org.eclipse.aether; +import java.util.Objects; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -38,10 +40,7 @@ public final class DefaultSessionData public void set( Object key, Object value ) { - if ( key == null ) - { - throw new IllegalArgumentException( "key must not be null" ); - } + Objects.requireNonNull( key, "key cannot be null" ); if ( value != null ) { @@ -55,10 +54,7 @@ public final class DefaultSessionData public boolean set( Object key, Object oldValue, Object newValue ) { - if ( key == null ) - { - throw new IllegalArgumentException( "key must not be null" ); - } + Objects.requireNonNull( key, "key cannot be null" ); if ( newValue != null ) { @@ -80,10 +76,7 @@ public final class DefaultSessionData public Object get( Object key ) { - if ( key == null ) - { - throw new IllegalArgumentException( "key must not be null" ); - } + Objects.requireNonNull( key, "key cannot be null" ); return data.get( key ); } http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-api/src/main/java/org/eclipse/aether/RepositoryEvent.java ---------------------------------------------------------------------- diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/RepositoryEvent.java b/maven-resolver-api/src/main/java/org/eclipse/aether/RepositoryEvent.java index 33816ba..f042508 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/RepositoryEvent.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/RepositoryEvent.java @@ -22,6 +22,7 @@ package org.eclipse.aether; import java.io.File; import java.util.Collections; import java.util.List; +import java.util.Objects; import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.metadata.Metadata; @@ -310,27 +311,19 @@ public final class RepositoryEvent /** * Creates a new event builder for the specified session and event type. - * + * * @param session The repository system session, must not be {@code null}. * @param type The type of the event, must not be {@code null}. */ public Builder( RepositorySystemSession session, EventType type ) { - if ( session == null ) - { - throw new IllegalArgumentException( "session not specified" ); - } - this.session = session; - if ( type == null ) - { - throw new IllegalArgumentException( "event type not specified" ); - } - this.type = type; + this.session = Objects.requireNonNull( session, "session cannot be null" ); + this.type = Objects.requireNonNull( type, "event type cannot be null" ); } /** * Sets the artifact involved in the event. - * + * * @param artifact The involved artifact, may be {@code null}. * @return This event builder for chaining, never {@code null}. */ http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/DefaultArtifactType.java ---------------------------------------------------------------------- diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/DefaultArtifactType.java b/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/DefaultArtifactType.java index c0d2ad8..7d44866 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/DefaultArtifactType.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/artifact/DefaultArtifactType.java @@ -22,6 +22,7 @@ package org.eclipse.aether.artifact; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.Objects; /** * A simple artifact type. @@ -83,11 +84,11 @@ public final class DefaultArtifactType public DefaultArtifactType( String id, String extension, String classifier, String language, boolean constitutesBuildPath, boolean includesDependencies ) { - if ( id == null || id.length() < 0 ) + this.id = Objects.requireNonNull( id, "type id cannot be null" ); + if ( id.length() == 0 ) { - throw new IllegalArgumentException( "no type id specified" ); + throw new IllegalArgumentException( "type id cannot be empty" ); } - this.id = id; this.extension = emptify( extension ); this.classifier = emptify( classifier ); Map<String, String> props = new HashMap<String, String>(); @@ -108,11 +109,11 @@ public final class DefaultArtifactType */ public DefaultArtifactType( String id, String extension, String classifier, Map<String, String> properties ) { - if ( id == null || id.length() < 0 ) + this.id = Objects.requireNonNull( id, "type id cannot be null" ); + if ( id.length() == 0 ) { - throw new IllegalArgumentException( "no type id specified" ); + throw new IllegalArgumentException( "type id cannot be empty" ); } - this.id = id; this.extension = emptify( extension ); this.classifier = emptify( classifier ); this.properties = AbstractArtifact.copyProperties( properties ); http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-api/src/main/java/org/eclipse/aether/collection/CollectResult.java ---------------------------------------------------------------------- diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/collection/CollectResult.java b/maven-resolver-api/src/main/java/org/eclipse/aether/collection/CollectResult.java index dd9f02e..63b99f0 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/collection/CollectResult.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/collection/CollectResult.java @@ -22,6 +22,7 @@ package org.eclipse.aether.collection; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Objects; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; @@ -46,23 +47,19 @@ public final class CollectResult /** * Creates a new result for the specified request. - * + * * @param request The resolution request, must not be {@code null}. */ public CollectResult( CollectRequest request ) { - if ( request == null ) - { - throw new IllegalArgumentException( "dependency collection request has not been specified" ); - } - this.request = request; + this.request = Objects.requireNonNull( request, "dependency collection request cannot be null" ); exceptions = Collections.emptyList(); cycles = Collections.emptyList(); } /** * Gets the collection request that was made. - * + * * @return The collection request, never {@code null}. */ public CollectRequest getRequest() http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-api/src/main/java/org/eclipse/aether/deployment/DeployResult.java ---------------------------------------------------------------------- diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/deployment/DeployResult.java b/maven-resolver-api/src/main/java/org/eclipse/aether/deployment/DeployResult.java index f75705e..dbe6b1c 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/deployment/DeployResult.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/deployment/DeployResult.java @@ -22,6 +22,7 @@ package org.eclipse.aether.deployment; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.Objects; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; @@ -44,23 +45,19 @@ public final class DeployResult /** * Creates a new result for the specified request. - * + * * @param request The deployment request, must not be {@code null}. */ public DeployResult( DeployRequest request ) { - if ( request == null ) - { - throw new IllegalArgumentException( "deploy request has not been specified" ); - } - this.request = request; + this.request = Objects.requireNonNull( request, "deploy request cannot be null" ); artifacts = Collections.emptyList(); metadata = Collections.emptyList(); } /** * Gets the deploy request that was made. - * + * * @return The deploy request, never {@code null}. */ public DeployRequest getRequest() http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-api/src/main/java/org/eclipse/aether/graph/DefaultDependencyNode.java ---------------------------------------------------------------------- diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/graph/DefaultDependencyNode.java b/maven-resolver-api/src/main/java/org/eclipse/aether/graph/DefaultDependencyNode.java index a2ffd0c..61724dd 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/graph/DefaultDependencyNode.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/graph/DefaultDependencyNode.java @@ -25,6 +25,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.repository.RemoteRepository; @@ -342,10 +343,7 @@ public final class DefaultDependencyNode public void setData( Object key, Object value ) { - if ( key == null ) - { - throw new IllegalArgumentException( "key must not be null" ); - } + Objects.requireNonNull( key, "key cannot be null" ); if ( value == null ) { http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-api/src/main/java/org/eclipse/aether/graph/Dependency.java ---------------------------------------------------------------------- diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/graph/Dependency.java b/maven-resolver-api/src/main/java/org/eclipse/aether/graph/Dependency.java index b9e7cb4..5f4d03b 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/graph/Dependency.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/graph/Dependency.java @@ -25,6 +25,7 @@ import java.util.Collections; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.NoSuchElementException; +import java.util.Objects; import java.util.Set; import org.eclipse.aether.artifact.Artifact; @@ -83,11 +84,7 @@ public final class Dependency private Dependency( Artifact artifact, String scope, Set<Exclusion> exclusions, Boolean optional ) { // NOTE: This constructor assumes immutability of the provided exclusion collection, for internal use only - if ( artifact == null ) - { - throw new IllegalArgumentException( "no artifact specified for dependency" ); - } - this.artifact = artifact; + this.artifact = Objects.requireNonNull( artifact, "artifact cannot be null" ); this.scope = ( scope != null ) ? scope : ""; this.optional = optional; this.exclusions = exclusions; http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-api/src/main/java/org/eclipse/aether/installation/InstallResult.java ---------------------------------------------------------------------- diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/installation/InstallResult.java b/maven-resolver-api/src/main/java/org/eclipse/aether/installation/InstallResult.java index 6624585..1ba0d62 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/installation/InstallResult.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/installation/InstallResult.java @@ -22,6 +22,7 @@ package org.eclipse.aether.installation; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.Objects; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; @@ -44,23 +45,19 @@ public final class InstallResult /** * Creates a new result for the specified request. - * + * * @param request The installation request, must not be {@code null}. */ public InstallResult( InstallRequest request ) { - if ( request == null ) - { - throw new IllegalArgumentException( "install request has not been specified" ); - } - this.request = request; + this.request = Objects.requireNonNull( request, "install request cannot be null" ); artifacts = Collections.emptyList(); metadata = Collections.emptyList(); } /** * Gets the install request that was made. - * + * * @return The install request, never {@code null}. */ public InstallRequest getRequest() http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-api/src/main/java/org/eclipse/aether/metadata/DefaultMetadata.java ---------------------------------------------------------------------- diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/metadata/DefaultMetadata.java b/maven-resolver-api/src/main/java/org/eclipse/aether/metadata/DefaultMetadata.java index 1efbb72..d5ee17c 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/metadata/DefaultMetadata.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/metadata/DefaultMetadata.java @@ -21,6 +21,7 @@ package org.eclipse.aether.metadata; import java.io.File; import java.util.Map; +import java.util.Objects; /** * A basic metadata instance. <em>Note:</em> Instances of this class are immutable and the exposed mutators return new @@ -127,11 +128,7 @@ public final class DefaultMetadata this.artifactId = emptify( artifactId ); this.version = emptify( version ); this.type = emptify( type ); - if ( nature == null ) - { - throw new IllegalArgumentException( "metadata nature was not specified" ); - } - this.nature = nature; + this.nature = Objects.requireNonNull( nature, "metadata nature cannot be null" ); this.file = file; this.properties = copyProperties( properties ); } http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-api/src/main/java/org/eclipse/aether/repository/AuthenticationContext.java ---------------------------------------------------------------------- diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/repository/AuthenticationContext.java b/maven-resolver-api/src/main/java/org/eclipse/aether/repository/AuthenticationContext.java index bd248a0..5c42b93 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/repository/AuthenticationContext.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/repository/AuthenticationContext.java @@ -24,6 +24,7 @@ import java.io.File; import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import org.eclipse.aether.RepositorySystemSession; @@ -179,11 +180,7 @@ public final class AuthenticationContext private AuthenticationContext( RepositorySystemSession session, RemoteRepository repository, Proxy proxy, Authentication auth ) { - if ( session == null ) - { - throw new IllegalArgumentException( "repository system session missing" ); - } - this.session = session; + this.session = Objects.requireNonNull( session, "repository system session cannot be null" ); this.repository = repository; this.proxy = proxy; this.auth = auth; @@ -257,10 +254,12 @@ public final class AuthenticationContext */ public <T> T get( String key, Map<String, String> data, Class<T> type ) { - if ( key == null ) + Objects.requireNonNull( key, "authentication key cannot be null" ); + if ( key.length() == 0 ) { - throw new IllegalArgumentException( "authentication data key missing" ); + throw new IllegalArgumentException( "authentication key cannot be empty" ); } + Object value; synchronized ( authData ) { @@ -333,16 +332,18 @@ public final class AuthenticationContext * Puts the specified authentication data into this context. This method should only be called from implementors of * {@link Authentication#fill(AuthenticationContext, String, Map)}. Passed in character arrays are not cloned and * become owned by this context, i.e. get erased when the context gets closed. - * + * * @param key The key to associate the authentication data with, must not be {@code null}. * @param value The (cleartext) authentication data to store, may be {@code null}. */ public void put( String key, Object value ) { - if ( key == null ) + Objects.requireNonNull( key, "authentication key cannot be null" ); + if ( key.length() == 0 ) { - throw new IllegalArgumentException( "authentication data key missing" ); + throw new IllegalArgumentException( "authentication key cannot be empty" ); } + synchronized ( authData ) { Object oldValue = authData.put( key, value ); http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-api/src/main/java/org/eclipse/aether/repository/LocalArtifactResult.java ---------------------------------------------------------------------- diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/repository/LocalArtifactResult.java b/maven-resolver-api/src/main/java/org/eclipse/aether/repository/LocalArtifactResult.java index e611b27..2ab7243 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/repository/LocalArtifactResult.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/repository/LocalArtifactResult.java @@ -20,12 +20,13 @@ package org.eclipse.aether.repository; */ import java.io.File; +import java.util.Objects; import org.eclipse.aether.RepositorySystemSession; /** * A result from the local repository about the existence of an artifact. - * + * * @see LocalRepositoryManager#find(RepositorySystemSession, LocalArtifactRequest) */ public final class LocalArtifactResult @@ -41,21 +42,17 @@ public final class LocalArtifactResult /** * Creates a new result for the specified request. - * + * * @param request The local artifact request, must not be {@code null}. */ public LocalArtifactResult( LocalArtifactRequest request ) { - if ( request == null ) - { - throw new IllegalArgumentException( "local artifact request has not been specified" ); - } - this.request = request; + this.request = Objects.requireNonNull( request, "local artifact request cannot be null" ); } /** * Gets the request corresponding to this result. - * + * * @return The corresponding request, never {@code null}. */ public LocalArtifactRequest getRequest() http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-api/src/main/java/org/eclipse/aether/repository/LocalMetadataResult.java ---------------------------------------------------------------------- diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/repository/LocalMetadataResult.java b/maven-resolver-api/src/main/java/org/eclipse/aether/repository/LocalMetadataResult.java index 29bd045..16e15bf 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/repository/LocalMetadataResult.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/repository/LocalMetadataResult.java @@ -20,12 +20,13 @@ package org.eclipse.aether.repository; */ import java.io.File; +import java.util.Objects; import org.eclipse.aether.RepositorySystemSession; /** * A result from the local repository about the existence of metadata. - * + * * @see LocalRepositoryManager#find(RepositorySystemSession, LocalMetadataRequest) */ public final class LocalMetadataResult @@ -39,21 +40,17 @@ public final class LocalMetadataResult /** * Creates a new result for the specified request. - * + * * @param request The local metadata request, must not be {@code null}. */ public LocalMetadataResult( LocalMetadataRequest request ) { - if ( request == null ) - { - throw new IllegalArgumentException( "local metadata request has not been specified" ); - } - this.request = request; + this.request = Objects.requireNonNull( request, "local metadata request cannot be null" ); } /** * Gets the request corresponding to this result. - * + * * @return The corresponding request, never {@code null}. */ public LocalMetadataRequest getRequest() http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-api/src/main/java/org/eclipse/aether/repository/RemoteRepository.java ---------------------------------------------------------------------- diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/repository/RemoteRepository.java b/maven-resolver-api/src/main/java/org/eclipse/aether/repository/RemoteRepository.java index 31259ca..09418c0 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/repository/RemoteRepository.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/repository/RemoteRepository.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Objects; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -335,22 +336,18 @@ public final class RemoteRepository * Creates a new repository builder which uses the specified remote repository as a prototype for the new one. * All properties which have not been set on the builder will be copied from the prototype when building the * repository. - * + * * @param prototype The remote repository to use as prototype, must not be {@code null}. */ public Builder( RemoteRepository prototype ) { - if ( prototype == null ) - { - throw new IllegalArgumentException( "repository prototype missing" ); - } - this.prototype = prototype; + this.prototype = Objects.requireNonNull( prototype, "remote repository prototype cannot be null" ); } /** * Builds a new remote repository from the current values of this builder. The state of the builder itself * remains unchanged. - * + * * @return The remote repository, never {@code null}. */ public RemoteRepository build() http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/ArtifactDescriptorResult.java ---------------------------------------------------------------------- diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/ArtifactDescriptorResult.java b/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/ArtifactDescriptorResult.java index 4c53b6e..728ce48 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/ArtifactDescriptorResult.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/ArtifactDescriptorResult.java @@ -24,6 +24,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Objects; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; @@ -62,16 +63,12 @@ public final class ArtifactDescriptorResult /** * Creates a new result for the specified request. - * + * * @param request The descriptor request, must not be {@code null}. */ public ArtifactDescriptorResult( ArtifactDescriptorRequest request ) { - if ( request == null ) - { - throw new IllegalArgumentException( "artifact descriptor request has not been specified" ); - } - this.request = request; + this.request = Objects.requireNonNull( request, "artifact descriptor request cannot be null" ); artifact = request.getArtifact(); exceptions = Collections.emptyList(); relocations = Collections.emptyList(); http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/ArtifactResult.java ---------------------------------------------------------------------- diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/ArtifactResult.java b/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/ArtifactResult.java index 5ae820b..7970036 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/ArtifactResult.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/ArtifactResult.java @@ -22,6 +22,7 @@ package org.eclipse.aether.resolution; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Objects; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; @@ -48,22 +49,18 @@ public final class ArtifactResult /** * Creates a new result for the specified request. - * + * * @param request The resolution request, must not be {@code null}. */ public ArtifactResult( ArtifactRequest request ) { - if ( request == null ) - { - throw new IllegalArgumentException( "resolution request has not been specified" ); - } - this.request = request; + this.request = Objects.requireNonNull( request, "artifact request cannot be null" ); exceptions = Collections.emptyList(); } /** * Gets the resolution request that was made. - * + * * @return The resolution request, never {@code null}. */ public ArtifactRequest getRequest() http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/DependencyResult.java ---------------------------------------------------------------------- diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/DependencyResult.java b/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/DependencyResult.java index 030e923..d3bcd9f 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/DependencyResult.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/DependencyResult.java @@ -21,6 +21,7 @@ package org.eclipse.aether.resolution; import java.util.Collections; import java.util.List; +import java.util.Objects; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; @@ -47,16 +48,12 @@ public final class DependencyResult /** * Creates a new result for the specified request. - * + * * @param request The resolution request, must not be {@code null}. */ public DependencyResult( DependencyRequest request ) { - if ( request == null ) - { - throw new IllegalArgumentException( "dependency request has not been specified" ); - } - this.request = request; + this.request = Objects.requireNonNull( request, "dependency request cannot be null" ); root = request.getRoot(); cycles = Collections.emptyList(); collectExceptions = Collections.emptyList(); http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/MetadataResult.java ---------------------------------------------------------------------- diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/MetadataResult.java b/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/MetadataResult.java index 2bba499..713eab2 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/MetadataResult.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/MetadataResult.java @@ -1,5 +1,7 @@ package org.eclipse.aether.resolution; +import java.util.Objects; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -42,21 +44,17 @@ public final class MetadataResult /** * Creates a new result for the specified request. - * + * * @param request The resolution request, must not be {@code null}. */ public MetadataResult( MetadataRequest request ) { - if ( request == null ) - { - throw new IllegalArgumentException( "metadata request has not been specified" ); - } - this.request = request; + this.request = Objects.requireNonNull( request, "metadata request cannot be null" ); } /** * Gets the resolution request that was made. - * + * * @return The resolution request, never {@code null}. */ public MetadataRequest getRequest() http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/VersionRangeResult.java ---------------------------------------------------------------------- diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/VersionRangeResult.java b/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/VersionRangeResult.java index 4749f7c..a397aea 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/VersionRangeResult.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/VersionRangeResult.java @@ -24,6 +24,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; @@ -51,16 +52,12 @@ public final class VersionRangeResult /** * Creates a new result for the specified request. - * + * * @param request The resolution request, must not be {@code null}. */ public VersionRangeResult( VersionRangeRequest request ) { - if ( request == null ) - { - throw new IllegalArgumentException( "version range request has not been specified" ); - } - this.request = request; + this.request = Objects.requireNonNull( request, "version range request cannot be null" ); exceptions = Collections.emptyList(); versions = Collections.emptyList(); repositories = Collections.emptyMap(); http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/VersionResult.java ---------------------------------------------------------------------- diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/VersionResult.java b/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/VersionResult.java index 5125773..a82b5c6 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/VersionResult.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/resolution/VersionResult.java @@ -22,6 +22,7 @@ package org.eclipse.aether.resolution; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Objects; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; @@ -45,22 +46,18 @@ public final class VersionResult /** * Creates a new result for the specified request. - * + * * @param request The resolution request, must not be {@code null}. */ public VersionResult( VersionRequest request ) { - if ( request == null ) - { - throw new IllegalArgumentException( "version request has not been specified" ); - } - this.request = request; + this.request = Objects.requireNonNull( request, "version request cannot be null" ); exceptions = Collections.emptyList(); } /** * Gets the resolution request that was made. - * + * * @return The resolution request, never {@code null}. */ public VersionRequest getRequest() http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-api/src/main/java/org/eclipse/aether/transfer/TransferEvent.java ---------------------------------------------------------------------- diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/transfer/TransferEvent.java b/maven-resolver-api/src/main/java/org/eclipse/aether/transfer/TransferEvent.java index a78b6e3..682de4e 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/transfer/TransferEvent.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/transfer/TransferEvent.java @@ -20,12 +20,13 @@ package org.eclipse.aether.transfer; */ import java.nio.ByteBuffer; +import java.util.Objects; import org.eclipse.aether.RepositorySystemSession; /** * An event fired to a transfer listener during an artifact/metadata transfer. - * + * * @see TransferListener * @see TransferEvent.Builder */ @@ -237,22 +238,14 @@ public final class TransferEvent /** * Creates a new transfer event builder for the specified session and the given resource. - * + * * @param session The repository system session, must not be {@code null}. * @param resource The resource being transferred, must not be {@code null}. */ public Builder( RepositorySystemSession session, TransferResource resource ) { - if ( session == null ) - { - throw new IllegalArgumentException( "session not specified" ); - } - if ( resource == null ) - { - throw new IllegalArgumentException( "transfer resource not specified" ); - } - this.session = session; - this.resource = resource; + this.session = Objects.requireNonNull( session, "repository system session cannot be null" ); + this.resource = Objects.requireNonNull( resource, "transfer resource cannot be null" ); type = EventType.INITIATED; requestType = RequestType.GET; } @@ -283,17 +276,13 @@ public final class TransferEvent * Sets the type of the event and resets event-specific fields. In more detail, the data buffer and the * exception fields are set to {@code null}. Furthermore, the total number of transferred bytes is set to * {@code 0} if the event type is {@link EventType#STARTED}. - * + * * @param type The type of the event, must not be {@code null}. * @return This event builder for chaining, never {@code null}. */ public Builder resetType( EventType type ) { - if ( type == null ) - { - throw new IllegalArgumentException( "event type not specified" ); - } - this.type = type; + this.type = Objects.requireNonNull( type, "event type cannot be null" ); dataBuffer = null; exception = null; switch ( type ) @@ -309,33 +298,25 @@ public final class TransferEvent /** * Sets the type of the event. When re-using the same builder to generate a sequence of events for one transfer, * {@link #resetType(TransferEvent.EventType)} might be more handy. - * + * * @param type The type of the event, must not be {@code null}. * @return This event builder for chaining, never {@code null}. */ public Builder setType( EventType type ) { - if ( type == null ) - { - throw new IllegalArgumentException( "event type not specified" ); - } - this.type = type; + this.type = Objects.requireNonNull( type, "event type cannot be null" ); return this; } /** * Sets the type of the request/transfer. - * + * * @param requestType The request/transfer type, must not be {@code null}. * @return This event builder for chaining, never {@code null}. */ public Builder setRequestType( RequestType requestType ) { - if ( requestType == null ) - { - throw new IllegalArgumentException( "request type not specified" ); - } - this.requestType = requestType; + this.requestType = Objects.requireNonNull( requestType, "request type cannot be null" ); return this; } http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-api/src/main/java/org/eclipse/aether/version/VersionRange.java ---------------------------------------------------------------------- diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/version/VersionRange.java b/maven-resolver-api/src/main/java/org/eclipse/aether/version/VersionRange.java index e355cf5..c747eeb 100644 --- a/maven-resolver-api/src/main/java/org/eclipse/aether/version/VersionRange.java +++ b/maven-resolver-api/src/main/java/org/eclipse/aether/version/VersionRange.java @@ -1,5 +1,7 @@ package org.eclipse.aether.version; +import java.util.Objects; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -61,23 +63,19 @@ public interface VersionRange /** * Creates a new bound with the specified properties. - * + * * @param version The bounding version, must not be {@code null}. * @param inclusive A flag whether the specified version is included in the range or not. */ public Bound( Version version, boolean inclusive ) { - if ( version == null ) - { - throw new IllegalArgumentException( "version missing" ); - } - this.version = version; + this.version = Objects.requireNonNull( version, "version cannot be null" ); this.inclusive = inclusive; } /** * Gets the bounding version. - * + * * @return The bounding version, never {@code null}. */ public Version getVersion() http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-api/src/test/java/org/eclipse/aether/repository/RemoteRepositoryBuilderTest.java ---------------------------------------------------------------------- diff --git a/maven-resolver-api/src/test/java/org/eclipse/aether/repository/RemoteRepositoryBuilderTest.java b/maven-resolver-api/src/test/java/org/eclipse/aether/repository/RemoteRepositoryBuilderTest.java index a384705..e2c15e3 100644 --- a/maven-resolver-api/src/test/java/org/eclipse/aether/repository/RemoteRepositoryBuilderTest.java +++ b/maven-resolver-api/src/test/java/org/eclipse/aether/repository/RemoteRepositoryBuilderTest.java @@ -48,7 +48,7 @@ public class RemoteRepositoryBuilderTest assertSame( prototype, builder.build() ); } - @Test( expected = IllegalArgumentException.class ) + @Test( expected = NullPointerException.class ) public void testPrototypeMandatory() { new Builder( null ); http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnector.java ---------------------------------------------------------------------- diff --git a/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnector.java b/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnector.java index 4f2e37e..51eca65 100644 --- a/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnector.java +++ b/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnector.java @@ -27,6 +27,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; @@ -400,7 +401,7 @@ final class BasicRepositoryConnector List<RepositoryLayout.Checksum> checksums, TransferTransportListener<?> listener ) { super( path, listener ); - this.file = file; + this.file = Objects.requireNonNull( file, "destination file cannot be null" ); checksumValidator = new ChecksumValidator( logger, file, fileProcessor, this, checksumPolicy, safe( checksums ) ); } @@ -432,10 +433,6 @@ final class BasicRepositoryConnector protected void runTask() throws Exception { - if ( file == null ) - { - throw new IllegalArgumentException( "destination file has not been specified" ); - } fileProcessor.mkdirs( file.getParentFile() ); PartialFile partFile = partialFileFactory.newInstance( file, this ); @@ -505,17 +502,13 @@ final class BasicRepositoryConnector TransferTransportListener<?> listener ) { super( path, listener ); - this.file = file; + this.file = Objects.requireNonNull( file, "source file cannot be null" );; this.checksums = safe( checksums ); } protected void runTask() throws Exception { - if ( file == null ) - { - throw new IllegalArgumentException( "source file has not been specified" ); - } transporter.put( new PutTask( path ).setDataFile( file ).setListener( listener ) ); uploadChecksums( file, path ); } http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnectorFactory.java ---------------------------------------------------------------------- diff --git a/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnectorFactory.java b/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnectorFactory.java index 8338daf..f308d0c 100644 --- a/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnectorFactory.java +++ b/maven-resolver-connector-basic/src/main/java/org/eclipse/aether/connector/basic/BasicRepositoryConnectorFactory.java @@ -1,5 +1,7 @@ package org.eclipse.aether.connector.basic; +import java.util.Objects; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -104,65 +106,49 @@ public final class BasicRepositoryConnectorFactory /** * Sets the transporter provider to use for this component. - * + * * @param transporterProvider The transporter provider to use, must not be {@code null}. * @return This component for chaining, never {@code null}. */ public BasicRepositoryConnectorFactory setTransporterProvider( TransporterProvider transporterProvider ) { - if ( transporterProvider == null ) - { - throw new IllegalArgumentException( "transporter provider has not been specified" ); - } - this.transporterProvider = transporterProvider; + this.transporterProvider = Objects.requireNonNull( transporterProvider, "transporter provider cannot be null" ); return this; } /** * Sets the repository layout provider to use for this component. - * + * * @param layoutProvider The repository layout provider to use, must not be {@code null}. * @return This component for chaining, never {@code null}. */ public BasicRepositoryConnectorFactory setRepositoryLayoutProvider( RepositoryLayoutProvider layoutProvider ) { - if ( layoutProvider == null ) - { - throw new IllegalArgumentException( "repository layout provider has not been specified" ); - } - this.layoutProvider = layoutProvider; + this.layoutProvider = Objects.requireNonNull( layoutProvider, "repository layout provider cannot be null" ); return this; } /** * Sets the checksum policy provider to use for this component. - * + * * @param checksumPolicyProvider The checksum policy provider to use, must not be {@code null}. * @return This component for chaining, never {@code null}. */ public BasicRepositoryConnectorFactory setChecksumPolicyProvider( ChecksumPolicyProvider checksumPolicyProvider ) { - if ( checksumPolicyProvider == null ) - { - throw new IllegalArgumentException( "checksum policy provider has not been specified" ); - } - this.checksumPolicyProvider = checksumPolicyProvider; + this.checksumPolicyProvider = Objects.requireNonNull( checksumPolicyProvider, "checksum policy provider cannot be null" ); return this; } /** * Sets the file processor to use for this component. - * + * * @param fileProcessor The file processor to use, must not be {@code null}. * @return This component for chaining, never {@code null}. */ public BasicRepositoryConnectorFactory setFileProcessor( FileProcessor fileProcessor ) { - if ( fileProcessor == null ) - { - throw new IllegalArgumentException( "file processor has not been specified" ); - } - this.fileProcessor = fileProcessor; + this.fileProcessor = Objects.requireNonNull( fileProcessor, "file processor cannot be null" ); return this; } http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/DefaultServiceLocator.java ---------------------------------------------------------------------- diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/DefaultServiceLocator.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/DefaultServiceLocator.java index 4d71b88..6580361 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/DefaultServiceLocator.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/DefaultServiceLocator.java @@ -28,6 +28,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.internal.impl.DefaultArtifactResolver; @@ -90,11 +91,7 @@ public final class DefaultServiceLocator public Entry( Class<T> type ) { - if ( type == null ) - { - throw new IllegalArgumentException( "service type not specified" ); - } - this.type = type; + this.type = Objects.requireNonNull( type, "service type cannot be null" ); providers = new LinkedHashSet<Object>( 8 ); } @@ -105,11 +102,7 @@ public final class DefaultServiceLocator { for ( T service : services ) { - if ( service == null ) - { - throw new IllegalArgumentException( "service instance not specified" ); - } - providers.add( service ); + providers.add( Objects.requireNonNull( service, "service instance cannot be null" ) ); } } instances = null; @@ -123,11 +116,7 @@ public final class DefaultServiceLocator public synchronized void addService( Class<? extends T> impl ) { - if ( impl == null ) - { - throw new IllegalArgumentException( "implementation class not specified" ); - } - providers.add( impl ); + providers.add( Objects.requireNonNull( impl, "implementation class cannot be null" ) ); instances = null; } @@ -234,12 +223,8 @@ public final class DefaultServiceLocator private <T> Entry<T> getEntry( Class<T> type, boolean create ) { - if ( type == null ) - { - throw new IllegalArgumentException( "service type not specified" ); - } @SuppressWarnings( "unchecked" ) - Entry<T> entry = (Entry<T>) entries.get( type ); + Entry<T> entry = (Entry<T>) entries.get( Objects.requireNonNull( type, "service type cannot be null" ) ); if ( entry == null && create ) { entry = new Entry<T>( type ); http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultArtifactResolver.java ---------------------------------------------------------------------- diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultArtifactResolver.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultArtifactResolver.java index 37d296e..2a3f4ca 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultArtifactResolver.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultArtifactResolver.java @@ -26,6 +26,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; +import java.util.Objects; import java.util.concurrent.atomic.AtomicBoolean; import javax.inject.Inject; @@ -148,81 +149,49 @@ public class DefaultArtifactResolver public DefaultArtifactResolver setFileProcessor( FileProcessor fileProcessor ) { - if ( fileProcessor == null ) - { - throw new IllegalArgumentException( "file processor has not been specified" ); - } - this.fileProcessor = fileProcessor; + this.fileProcessor = Objects.requireNonNull( fileProcessor, "file processor cannot be null" ); return this; } public DefaultArtifactResolver setRepositoryEventDispatcher( RepositoryEventDispatcher repositoryEventDispatcher ) { - if ( repositoryEventDispatcher == null ) - { - throw new IllegalArgumentException( "repository event dispatcher has not been specified" ); - } - this.repositoryEventDispatcher = repositoryEventDispatcher; + this.repositoryEventDispatcher = Objects.requireNonNull( repositoryEventDispatcher, "repository event dispatcher cannot be null" ); return this; } public DefaultArtifactResolver setVersionResolver( VersionResolver versionResolver ) { - if ( versionResolver == null ) - { - throw new IllegalArgumentException( "version resolver has not been specified" ); - } - this.versionResolver = versionResolver; + this.versionResolver = Objects.requireNonNull( versionResolver, "version resolver cannot be null" ); return this; } public DefaultArtifactResolver setUpdateCheckManager( UpdateCheckManager updateCheckManager ) { - if ( updateCheckManager == null ) - { - throw new IllegalArgumentException( "update check manager has not been specified" ); - } - this.updateCheckManager = updateCheckManager; + this.updateCheckManager = Objects.requireNonNull( updateCheckManager, "update check manager cannot be null" ); return this; } public DefaultArtifactResolver setRepositoryConnectorProvider( RepositoryConnectorProvider repositoryConnectorProvider ) { - if ( repositoryConnectorProvider == null ) - { - throw new IllegalArgumentException( "repository connector provider has not been specified" ); - } - this.repositoryConnectorProvider = repositoryConnectorProvider; + this.repositoryConnectorProvider = Objects.requireNonNull( repositoryConnectorProvider, "repository connector provider cannot be null" ); return this; } public DefaultArtifactResolver setRemoteRepositoryManager( RemoteRepositoryManager remoteRepositoryManager ) { - if ( remoteRepositoryManager == null ) - { - throw new IllegalArgumentException( "remote repository manager has not been specified" ); - } - this.remoteRepositoryManager = remoteRepositoryManager; + this.remoteRepositoryManager = Objects.requireNonNull( remoteRepositoryManager, "remote repository provider cannot be null" ); return this; } public DefaultArtifactResolver setSyncContextFactory( SyncContextFactory syncContextFactory ) { - if ( syncContextFactory == null ) - { - throw new IllegalArgumentException( "sync context factory has not been specified" ); - } - this.syncContextFactory = syncContextFactory; + this.syncContextFactory = Objects.requireNonNull( syncContextFactory, "sync context factory cannot be null" ); return this; } public DefaultArtifactResolver setOfflineController( OfflineController offlineController ) { - if ( offlineController == null ) - { - throw new IllegalArgumentException( "offline controller has not been specified" ); - } - this.offlineController = offlineController; + this.offlineController = Objects.requireNonNull( offlineController, "offline controller cannot be null" ); return this; } http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultDependencyCollector.java ---------------------------------------------------------------------- diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultDependencyCollector.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultDependencyCollector.java index 4fb8374..ff99586 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultDependencyCollector.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultDependencyCollector.java @@ -26,6 +26,7 @@ import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import javax.inject.Inject; import javax.inject.Named; @@ -121,31 +122,19 @@ public class DefaultDependencyCollector public DefaultDependencyCollector setRemoteRepositoryManager( RemoteRepositoryManager remoteRepositoryManager ) { - if ( remoteRepositoryManager == null ) - { - throw new IllegalArgumentException( "remote repository manager has not been specified" ); - } - this.remoteRepositoryManager = remoteRepositoryManager; + this.remoteRepositoryManager = Objects.requireNonNull( remoteRepositoryManager, "remote repository provider cannot be null" ); return this; } public DefaultDependencyCollector setArtifactDescriptorReader( ArtifactDescriptorReader artifactDescriptorReader ) { - if ( artifactDescriptorReader == null ) - { - throw new IllegalArgumentException( "artifact descriptor reader has not been specified" ); - } - descriptorReader = artifactDescriptorReader; + descriptorReader = Objects.requireNonNull( artifactDescriptorReader, "artifact descriptor reader cannot be null" ); return this; } public DefaultDependencyCollector setVersionRangeResolver( VersionRangeResolver versionRangeResolver ) { - if ( versionRangeResolver == null ) - { - throw new IllegalArgumentException( "version range resolver has not been specified" ); - } - this.versionRangeResolver = versionRangeResolver; + this.versionRangeResolver = Objects.requireNonNull( versionRangeResolver, "version range resolver cannot be null" ); return this; } http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultDependencyGraphTransformationContext.java ---------------------------------------------------------------------- diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultDependencyGraphTransformationContext.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultDependencyGraphTransformationContext.java index d877ad6..f82cfc1 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultDependencyGraphTransformationContext.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultDependencyGraphTransformationContext.java @@ -21,6 +21,7 @@ package org.eclipse.aether.internal.impl; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.collection.DependencyGraphTransformationContext; @@ -48,19 +49,12 @@ class DefaultDependencyGraphTransformationContext public Object get( Object key ) { - if ( key == null ) - { - throw new IllegalArgumentException( "key must not be null" ); - } - return map.get( key ); + return map.get( Objects.requireNonNull( key, "key cannot be null" ) ); } public Object put( Object key, Object value ) { - if ( key == null ) - { - throw new IllegalArgumentException( "key must not be null" ); - } + Objects.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/f4a0ce15/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultDeployer.java ---------------------------------------------------------------------- diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultDeployer.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultDeployer.java index 56951fa..ea5fb08 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultDeployer.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultDeployer.java @@ -26,6 +26,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.IdentityHashMap; import java.util.List; +import java.util.Objects; import java.util.Set; import javax.inject.Inject; @@ -143,61 +144,37 @@ public class DefaultDeployer public DefaultDeployer setFileProcessor( FileProcessor fileProcessor ) { - if ( fileProcessor == null ) - { - throw new IllegalArgumentException( "file processor has not been specified" ); - } - this.fileProcessor = fileProcessor; + this.fileProcessor = Objects.requireNonNull( fileProcessor, "file processor cannot be null" ); return this; } public DefaultDeployer setRepositoryEventDispatcher( RepositoryEventDispatcher repositoryEventDispatcher ) { - if ( repositoryEventDispatcher == null ) - { - throw new IllegalArgumentException( "repository event dispatcher has not been specified" ); - } - this.repositoryEventDispatcher = repositoryEventDispatcher; + this.repositoryEventDispatcher = Objects.requireNonNull( repositoryEventDispatcher, "repository event dispatcher cannot be null" ); return this; } public DefaultDeployer setRepositoryConnectorProvider( RepositoryConnectorProvider repositoryConnectorProvider ) { - if ( repositoryConnectorProvider == null ) - { - throw new IllegalArgumentException( "repository connector provider has not been specified" ); - } - this.repositoryConnectorProvider = repositoryConnectorProvider; + this.repositoryConnectorProvider = Objects.requireNonNull( repositoryConnectorProvider, "repository connector provider cannot be null" ); return this; } public DefaultDeployer setRemoteRepositoryManager( RemoteRepositoryManager remoteRepositoryManager ) { - if ( remoteRepositoryManager == null ) - { - throw new IllegalArgumentException( "remote repository manager has not been specified" ); - } - this.remoteRepositoryManager = remoteRepositoryManager; + this.remoteRepositoryManager = Objects.requireNonNull( remoteRepositoryManager, "remote repository provider cannot be null" ); return this; } public DefaultDeployer setUpdateCheckManager( UpdateCheckManager updateCheckManager ) { - if ( updateCheckManager == null ) - { - throw new IllegalArgumentException( "update check manager has not been specified" ); - } - this.updateCheckManager = updateCheckManager; + this.updateCheckManager = Objects.requireNonNull( updateCheckManager, "update check manager cannot be null" ); return this; } public DefaultDeployer addMetadataGeneratorFactory( MetadataGeneratorFactory factory ) { - if ( factory == null ) - { - throw new IllegalArgumentException( "metadata generator factory has not been specified" ); - } - metadataFactories.add( factory ); + metadataFactories.add( Objects.requireNonNull( factory, "metadata generator factory cannot be null" ) ); return this; } @@ -216,21 +193,13 @@ public class DefaultDeployer public DefaultDeployer setSyncContextFactory( SyncContextFactory syncContextFactory ) { - if ( syncContextFactory == null ) - { - throw new IllegalArgumentException( "sync context factory has not been specified" ); - } - this.syncContextFactory = syncContextFactory; + this.syncContextFactory = Objects.requireNonNull( syncContextFactory, "sync context factory cannot be null" ); return this; } public DefaultDeployer setOfflineController( OfflineController offlineController ) { - if ( offlineController == null ) - { - throw new IllegalArgumentException( "offline controller has not been specified" ); - } - this.offlineController = offlineController; + this.offlineController = Objects.requireNonNull( offlineController, "offline controller cannot be null" ); return this; } http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultInstaller.java ---------------------------------------------------------------------- diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultInstaller.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultInstaller.java index ea95371..6016b77 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultInstaller.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultInstaller.java @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.IdentityHashMap; import java.util.List; +import java.util.Objects; import java.util.Set; import javax.inject.Inject; @@ -106,31 +107,19 @@ public class DefaultInstaller public DefaultInstaller setFileProcessor( FileProcessor fileProcessor ) { - if ( fileProcessor == null ) - { - throw new IllegalArgumentException( "file processor has not been specified" ); - } - this.fileProcessor = fileProcessor; + this.fileProcessor = Objects.requireNonNull( fileProcessor, "file processor cannot be null" ); return this; } public DefaultInstaller setRepositoryEventDispatcher( RepositoryEventDispatcher repositoryEventDispatcher ) { - if ( repositoryEventDispatcher == null ) - { - throw new IllegalArgumentException( "repository event dispatcher has not been specified" ); - } - this.repositoryEventDispatcher = repositoryEventDispatcher; + this.repositoryEventDispatcher = Objects.requireNonNull( repositoryEventDispatcher, "repository event dispatcher cannot be null" ); return this; } public DefaultInstaller addMetadataGeneratorFactory( MetadataGeneratorFactory factory ) { - if ( factory == null ) - { - throw new IllegalArgumentException( "metadata generator factory has not been specified" ); - } - metadataFactories.add( factory ); + metadataFactories.add( Objects.requireNonNull( factory, "metadata generator factory cannot be null" ) ); return this; } @@ -149,11 +138,7 @@ public class DefaultInstaller public DefaultInstaller setSyncContextFactory( SyncContextFactory syncContextFactory ) { - if ( syncContextFactory == null ) - { - throw new IllegalArgumentException( "sync context factory has not been specified" ); - } - this.syncContextFactory = syncContextFactory; + this.syncContextFactory = Objects.requireNonNull( syncContextFactory, "sync context factory cannot be null" ); return this; } http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultLocalRepositoryProvider.java ---------------------------------------------------------------------- diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultLocalRepositoryProvider.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultLocalRepositoryProvider.java index 1f0597a..c926ca3 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultLocalRepositoryProvider.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultLocalRepositoryProvider.java @@ -22,6 +22,7 @@ package org.eclipse.aether.internal.impl; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Objects; import java.util.Set; import javax.inject.Inject; @@ -76,11 +77,7 @@ public class DefaultLocalRepositoryProvider public DefaultLocalRepositoryProvider addLocalRepositoryManagerFactory( LocalRepositoryManagerFactory factory ) { - if ( factory == null ) - { - throw new IllegalArgumentException( "Local repository manager factory has not been specified." ); - } - managerFactories.add( factory ); + managerFactories.add( Objects.requireNonNull( factory, "local repository manager factory cannot be null" ) ); return this; } http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultMetadataResolver.java ---------------------------------------------------------------------- diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultMetadataResolver.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultMetadataResolver.java index c751112..5e90cc8 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultMetadataResolver.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultMetadataResolver.java @@ -27,6 +27,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; import java.util.concurrent.LinkedBlockingQueue; @@ -138,61 +139,37 @@ public class DefaultMetadataResolver public DefaultMetadataResolver setRepositoryEventDispatcher( RepositoryEventDispatcher repositoryEventDispatcher ) { - if ( repositoryEventDispatcher == null ) - { - throw new IllegalArgumentException( "repository event dispatcher has not been specified" ); - } - this.repositoryEventDispatcher = repositoryEventDispatcher; + this.repositoryEventDispatcher = Objects.requireNonNull( repositoryEventDispatcher, "repository event dispatcher cannot be null" ); return this; } public DefaultMetadataResolver setUpdateCheckManager( UpdateCheckManager updateCheckManager ) { - if ( updateCheckManager == null ) - { - throw new IllegalArgumentException( "update check manager has not been specified" ); - } - this.updateCheckManager = updateCheckManager; + this.updateCheckManager = Objects.requireNonNull( updateCheckManager, "update check manager cannot be null" ); return this; } public DefaultMetadataResolver setRepositoryConnectorProvider( RepositoryConnectorProvider repositoryConnectorProvider ) { - if ( repositoryConnectorProvider == null ) - { - throw new IllegalArgumentException( "repository connector provider has not been specified" ); - } - this.repositoryConnectorProvider = repositoryConnectorProvider; + this.repositoryConnectorProvider = Objects.requireNonNull( repositoryConnectorProvider, "repository connector provider cannot be null" ); return this; } public DefaultMetadataResolver setRemoteRepositoryManager( RemoteRepositoryManager remoteRepositoryManager ) { - if ( remoteRepositoryManager == null ) - { - throw new IllegalArgumentException( "remote repository manager has not been specified" ); - } - this.remoteRepositoryManager = remoteRepositoryManager; + this.remoteRepositoryManager = Objects.requireNonNull( remoteRepositoryManager, "remote repository provider cannot be null" ); return this; } public DefaultMetadataResolver setSyncContextFactory( SyncContextFactory syncContextFactory ) { - if ( syncContextFactory == null ) - { - throw new IllegalArgumentException( "sync context factory has not been specified" ); - } - this.syncContextFactory = syncContextFactory; + this.syncContextFactory = Objects.requireNonNull( syncContextFactory, "sync context factory cannot be null" ); return this; } public DefaultMetadataResolver setOfflineController( OfflineController offlineController ) { - if ( offlineController == null ) - { - throw new IllegalArgumentException( "offline controller has not been specified" ); - } - this.offlineController = offlineController; + this.offlineController = Objects.requireNonNull( offlineController, "offline controller cannot be null" ); return this; } http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRemoteRepositoryManager.java ---------------------------------------------------------------------- diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRemoteRepositoryManager.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRemoteRepositoryManager.java index 148bf4d..674a3bc 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRemoteRepositoryManager.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRemoteRepositoryManager.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.ListIterator; +import java.util.Objects; import javax.inject.Inject; import javax.inject.Named; @@ -121,21 +122,13 @@ public class DefaultRemoteRepositoryManager public DefaultRemoteRepositoryManager setUpdatePolicyAnalyzer( UpdatePolicyAnalyzer updatePolicyAnalyzer ) { - if ( updatePolicyAnalyzer == null ) - { - throw new IllegalArgumentException( "update policy analyzer has not been specified" ); - } - this.updatePolicyAnalyzer = updatePolicyAnalyzer; + this.updatePolicyAnalyzer = Objects.requireNonNull( updatePolicyAnalyzer, "update policy analyzer cannot be null" ); return this; } public DefaultRemoteRepositoryManager setChecksumPolicyProvider( ChecksumPolicyProvider checksumPolicyProvider ) { - if ( checksumPolicyProvider == null ) - { - throw new IllegalArgumentException( "checksum policy provider has not been specified" ); - } - this.checksumPolicyProvider = checksumPolicyProvider; + this.checksumPolicyProvider = Objects.requireNonNull( checksumPolicyProvider, "checksum policy provider cannot be null" ); return this; } http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryConnectorProvider.java ---------------------------------------------------------------------- diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryConnectorProvider.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryConnectorProvider.java index 10fdc23..1994459 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryConnectorProvider.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryConnectorProvider.java @@ -22,6 +22,7 @@ package org.eclipse.aether.internal.impl; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Objects; import java.util.Set; import javax.inject.Inject; @@ -78,11 +79,7 @@ public class DefaultRepositoryConnectorProvider public DefaultRepositoryConnectorProvider addRepositoryConnectorFactory( RepositoryConnectorFactory factory ) { - if ( factory == null ) - { - throw new IllegalArgumentException( "repository connector factory has not been specified" ); - } - connectorFactories.add( factory ); + connectorFactories.add( Objects.requireNonNull( factory, "repository connector factory cannot be null" ) ); return this; } @@ -102,10 +99,7 @@ public class DefaultRepositoryConnectorProvider public RepositoryConnector newRepositoryConnector( RepositorySystemSession session, RemoteRepository repository ) throws NoRepositoryConnectorException { - if ( repository == null ) - { - throw new IllegalArgumentException( "remote repository has not been specified" ); - } + Objects.requireNonNull( repository, "remote repository cannot be null" ); PrioritizedComponents<RepositoryConnectorFactory> factories = new PrioritizedComponents<RepositoryConnectorFactory>( session ); http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryEventDispatcher.java ---------------------------------------------------------------------- diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryEventDispatcher.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryEventDispatcher.java index 2e56c93..d8421f8 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryEventDispatcher.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryEventDispatcher.java @@ -21,6 +21,7 @@ package org.eclipse.aether.internal.impl; import java.util.ArrayList; import java.util.Collection; +import java.util.Objects; import java.util.Set; import javax.inject.Inject; @@ -66,11 +67,7 @@ public class DefaultRepositoryEventDispatcher public DefaultRepositoryEventDispatcher addRepositoryListener( RepositoryListener listener ) { - if ( listener == null ) - { - throw new IllegalArgumentException( "repository listener has not been specified" ); - } - this.listeners.add( listener ); + this.listeners.add( Objects.requireNonNull( listener, "repository listener cannot be null" ) ); return this; } http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/f4a0ce15/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryLayoutProvider.java ---------------------------------------------------------------------- diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryLayoutProvider.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryLayoutProvider.java index 9cc6371..5190ed9 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryLayoutProvider.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositoryLayoutProvider.java @@ -22,6 +22,7 @@ package org.eclipse.aether.internal.impl; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Objects; import java.util.Set; import javax.inject.Inject; @@ -76,11 +77,7 @@ public final class DefaultRepositoryLayoutProvider public DefaultRepositoryLayoutProvider addRepositoryLayoutFactory( RepositoryLayoutFactory factory ) { - if ( factory == null ) - { - throw new IllegalArgumentException( "layout factory has not been specified" ); - } - factories.add( factory ); + factories.add( Objects.requireNonNull( factory, "layout factory cannot be null" ) ); return this; } @@ -100,10 +97,7 @@ public final class DefaultRepositoryLayoutProvider public RepositoryLayout newRepositoryLayout( RepositorySystemSession session, RemoteRepository repository ) throws NoRepositoryLayoutException { - if ( repository == null ) - { - throw new IllegalArgumentException( "remote repository has not been specified" ); - } + Objects.requireNonNull( repository, "remote repository cannot be null" ); PrioritizedComponents<RepositoryLayoutFactory> factories = new PrioritizedComponents<RepositoryLayoutFactory>( session );