[maven-resolver] branch master updated: [MRESOLVER-60] Possible NPE when calling RepositorySystemSession.getFileTransformerManager() Fix typo in methodName

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[maven-resolver] branch master updated: [MRESOLVER-60] Possible NPE when calling RepositorySystemSession.getFileTransformerManager() Fix typo in methodName

Robert Scholte-8
This is an automated email from the ASF dual-hosted git repository.

rfscholte pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git


The following commit(s) were added to refs/heads/master by this push:
     new 4cbd5dc  [MRESOLVER-60] Possible NPE when calling RepositorySystemSession.getFileTransformerManager() Fix typo in methodName
4cbd5dc is described below

commit 4cbd5dc4c46bd366833d659d177745e52a559e6f
Author: rfscholte <[hidden email]>
AuthorDate: Wed Oct 10 21:38:52 2018 +0200

    [MRESOLVER-60] Possible NPE when calling RepositorySystemSession.getFileTransformerManager()
    Fix typo in methodName
---
 maven-resolver-api/pom.xml                         |  6 ++++++
 .../AbstractForwardingRepositorySystemSession.java |  4 ++--
 .../aether/DefaultRepositorySystemSession.java     |  3 ++-
 .../eclipse/aether/RepositorySystemSession.java    |  2 +-
 .../aether/DefaultRepositorySystemSessionTest.java | 24 ++++++++++++++++++++--
 .../aether/internal/impl/DefaultDeployer.java      |  2 +-
 .../aether/internal/impl/DefaultInstaller.java     |  2 +-
 pom.xml                                            |  6 ++++++
 8 files changed, 41 insertions(+), 8 deletions(-)

diff --git a/maven-resolver-api/pom.xml b/maven-resolver-api/pom.xml
index 7de33c3..a2da815 100644
--- a/maven-resolver-api/pom.xml
+++ b/maven-resolver-api/pom.xml
@@ -51,6 +51,12 @@
       <artifactId>hamcrest-core</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+
   </dependencies>
 
   <build>
diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/AbstractForwardingRepositorySystemSession.java b/maven-resolver-api/src/main/java/org/eclipse/aether/AbstractForwardingRepositorySystemSession.java
index 35759cb..008a2df 100644
--- a/maven-resolver-api/src/main/java/org/eclipse/aether/AbstractForwardingRepositorySystemSession.java
+++ b/maven-resolver-api/src/main/java/org/eclipse/aether/AbstractForwardingRepositorySystemSession.java
@@ -213,9 +213,9 @@ public abstract class AbstractForwardingRepositorySystemSession
     }
     
     @Override
-    public FileTransformerManager geFileTransformerManager()
+    public FileTransformerManager getFileTransformerManager()
     {
-        return getSession().geFileTransformerManager();
+        return getSession().getFileTransformerManager();
     }
 
 }
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 8ba4e15..0335118 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
@@ -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;
     }
diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystemSession.java b/maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystemSession.java
index 025ec80..5a3f14c 100644
--- a/maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystemSession.java
+++ b/maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystemSession.java
@@ -266,6 +266,6 @@ public interface RepositorySystemSession
      *
      * @return the manager, never {@code null}
      */
-    FileTransformerManager geFileTransformerManager();
+    FileTransformerManager getFileTransformerManager();
 
 }
diff --git a/maven-resolver-api/src/test/java/org/eclipse/aether/DefaultRepositorySystemSessionTest.java b/maven-resolver-api/src/test/java/org/eclipse/aether/DefaultRepositorySystemSessionTest.java
index 91afeb5..911fd8f 100644
--- a/maven-resolver-api/src/test/java/org/eclipse/aether/DefaultRepositorySystemSessionTest.java
+++ b/maven-resolver-api/src/test/java/org/eclipse/aether/DefaultRepositorySystemSessionTest.java
@@ -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 );
+        }
+    }
+
 }
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 4d6f5be..31edb44 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
@@ -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>();
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 e4c998a..a517d74 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
@@ -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
--- a/pom.xml
+++ b/pom.xml
@@ -151,6 +151,12 @@
         <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>