[MRESOLVER-60] Possible NPE when calling RepositorySystemSession.getFileTransformerMa...
authorrfscholte <rfscholte@apache.org>
Wed, 10 Oct 2018 19:38:52 +0000 (21:38 +0200)
committerrfscholte <rfscholte@apache.org>
Wed, 10 Oct 2018 19:38:52 +0000 (21:38 +0200)
Fix typo in methodName

maven-resolver-api/pom.xml
maven-resolver-api/src/main/java/org/eclipse/aether/AbstractForwardingRepositorySystemSession.java
maven-resolver-api/src/main/java/org/eclipse/aether/DefaultRepositorySystemSession.java
maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystemSession.java
maven-resolver-api/src/test/java/org/eclipse/aether/DefaultRepositorySystemSessionTest.java
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultDeployer.java
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultInstaller.java
pom.xml

index 7de33c3..a2da815 100644 (file)
       <artifactId>hamcrest-core</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+
   </dependencies>
 
   <build>
index 35759cb..008a2df 100644 (file)
@@ -213,9 +213,9 @@ public abstract class AbstractForwardingRepositorySystemSession
     }
     
     @Override
-    public FileTransformerManager geFileTransformerManager()
+    public FileTransformerManager getFileTransformerManager()
     {
-        return getSession().geFileTransformerManager();
+        return getSession().getFileTransformerManager();
     }
 
 }
index 8ba4e15..0335118 100644 (file)
@@ -175,6 +175,7 @@ public final class DefaultRepositorySystemSession
         setDependencySelector( session.getDependencySelector() );
         setVersionFilter( session.getVersionFilter() );
         setDependencyGraphTransformer( session.getDependencyGraphTransformer() );
+        setFileTransformerManager( session.getFileTransformerManager() );
         setData( session.getData() );
         setCache( session.getCache() );
     }
@@ -326,7 +327,7 @@ public final class DefaultRepositorySystemSession
     }
 
     @Override
-    public FileTransformerManager geFileTransformerManager()
+    public FileTransformerManager getFileTransformerManager()
     {
         return fileTransformerManager;
     }
index 025ec80..5a3f14c 100644 (file)
@@ -266,6 +266,6 @@ public interface RepositorySystemSession
      * 
      * @return the manager, never {@code null}
      */
-    FileTransformerManager geFileTransformerManager();
+    FileTransformerManager getFileTransformerManager();
 
 }
index 91afeb5..911fd8f 100644 (file)
@@ -18,10 +18,13 @@ package org.eclipse.aether;
  * specific language governing permissions and limitations
  * under the License.
  */
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.fail;
 
-import static org.junit.Assert.*;
-
+import java.lang.reflect.Method;
 import java.util.Map;
+import java.util.Objects;
 
 import org.eclipse.aether.repository.Authentication;
 import org.eclipse.aether.repository.AuthenticationContext;
@@ -29,6 +32,7 @@ import org.eclipse.aether.repository.AuthenticationDigest;
 import org.eclipse.aether.repository.Proxy;
 import org.eclipse.aether.repository.RemoteRepository;
 import org.junit.Test;
+import org.mockito.Mockito;
 
 /**
  */
@@ -124,4 +128,20 @@ public class DefaultRepositorySystemSessionTest
         }
     }
 
+
+    @Test
+    public void testCopyRepositorySystemSession() throws Exception
+    {
+        RepositorySystemSession session = Mockito.mock( RepositorySystemSession.class, Mockito.RETURNS_MOCKS );
+
+        RepositorySystemSession newSession = new DefaultRepositorySystemSession( session );
+
+        Method[] methods = RepositorySystemSession.class.getMethods();
+
+        for ( Method method : methods )
+        {
+            assertEquals( method.getName(), method.invoke( session ) == null, method.invoke( newSession ) == null );
+        }
+    }
+
 }
index 4d6f5be..31edb44 100644 (file)
@@ -239,7 +239,7 @@ public class DefaultDeployer
         {
             List<? extends MetadataGenerator> generators = getMetadataGenerators( session, request );
 
-            FileTransformerManager fileTransformerManager = session.geFileTransformerManager();
+            FileTransformerManager fileTransformerManager = session.getFileTransformerManager();
 
             List<ArtifactUpload> artifactUploads = new ArrayList<ArtifactUpload>();
             List<MetadataUpload> metadataUploads = new ArrayList<MetadataUpload>();
index e4c998a..a517d74 100644 (file)
@@ -239,7 +239,7 @@ public class DefaultInstaller
 
         File srcFile = artifact.getFile();
 
-        Collection<FileTransformer> fileTransformers = session.geFileTransformerManager().getTransformersForArtifact( artifact );
+        Collection<FileTransformer> fileTransformers = session.getFileTransformerManager().getTransformersForArtifact( artifact );
         if ( fileTransformers.isEmpty() )
         {
             install( session, trace, artifact, lrm, srcFile, null );
diff --git a/pom.xml b/pom.xml
index 3a1c05b..d0df362 100644 (file)
--- a/pom.xml
+++ b/pom.xml
         <version>1.3</version>
         <scope>test</scope>
       </dependency>
+      <dependency>
+        <groupId>org.mockito</groupId>
+        <artifactId>mockito-core</artifactId>
+        <version>2.23.0</version>
+        <scope>test</scope>
+      </dependency>
 
       <dependency>
         <groupId>javax.inject</groupId>