You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2017/08/20 13:06:08 UTC

svn commit: r1805555 - /maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstaller.java

Author: khmarbaise
Date: Sun Aug 20 13:06:07 2017
New Revision: 1805555

URL: http://svn.apache.org/viewvc?rev=1805555&view=rev
Log:
[MSHARED-655] ArtifactInstaller check for integrity of parameters null, empty collection, being a directory
 o Followup added the implemented code which should be checked via unit tests.

Modified:
    maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstaller.java

Modified: maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstaller.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstaller.java?rev=1805555&r1=1805554&r2=1805555&view=diff
==============================================================================
--- maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstaller.java (original)
+++ maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstaller.java Sun Aug 20 13:06:07 2017
@@ -46,8 +46,21 @@ public class DefaultArtifactInstaller
 
     @Override
     public void install( ProjectBuildingRequest request, Collection<Artifact> mavenArtifacts )
-        throws ArtifactInstallerException
+        throws ArtifactInstallerException, IllegalArgumentException
     {
+        if ( request == null )
+        {
+            throw new IllegalArgumentException( "The parameter request is not allowed to be null." );
+        }
+        if ( mavenArtifacts == null )
+        {
+            throw new IllegalArgumentException( "The parameter mavenArtifacts is not allowed to be null." );
+        }
+        if ( mavenArtifacts.isEmpty() )
+        {
+            throw new IllegalArgumentException( "The collection mavenArtifacts is not allowed to be empty." );
+        }
+
         try
         {
             String hint = isMaven31() ? "maven31" : "maven3";
@@ -61,11 +74,32 @@ public class DefaultArtifactInstaller
             throw new ArtifactInstallerException( e.getMessage(), e );
         }
     }
-    
+
     @Override
     public void install( ProjectBuildingRequest request, File localRepositry, Collection<Artifact> mavenArtifacts )
         throws ArtifactInstallerException
     {
+        if ( request == null )
+        {
+            throw new IllegalArgumentException( "The parameter request is not allowed to be null." );
+        }
+        if ( localRepositry == null )
+        {
+            throw new IllegalArgumentException( "The parameter localRepository is not allowed to be null." );
+        }
+        if ( !localRepositry.isDirectory() )
+        {
+            throw new IllegalArgumentException( "The parameter localRepository must be a directory." );
+        }
+        if ( mavenArtifacts == null )
+        {
+            throw new IllegalArgumentException( "The parameter mavenArtifacts is not allowed to be null." );
+        }
+        if ( mavenArtifacts.isEmpty() )
+        {
+            throw new IllegalArgumentException( "The collection mavenArtifacts is not allowed to be empty." );
+        }
+
         try
         {
             String hint = isMaven31() ? "maven31" : "maven3";