You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2020/06/06 17:47:06 UTC

[maven-war-plugin] branch junit created (now fdcf860)

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

elharo pushed a change to branch junit
in repository https://gitbox.apache.org/repos/asf/maven-war-plugin.git.


      at fdcf860  clear up deprecations and resource leaks

This branch includes the following new commits:

     new fdcf860  clear up deprecations and resource leaks

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-war-plugin] 01/01: clear up deprecations and resource leaks

Posted by el...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

elharo pushed a commit to branch junit
in repository https://gitbox.apache.org/repos/asf/maven-war-plugin.git

commit fdcf860fa22dc70608aca8d4e003e816b42a6bd1
Author: Elliotte Rusty Harold <el...@ibiblio.org>
AuthorDate: Sat Jun 6 13:46:51 2020 -0400

    clear up deprecations and resource leaks
---
 pom.xml                                            |  2 +-
 .../maven/plugins/war/overlay/OverlayManager.java  | 12 ++---
 .../war/packaging/WarProjectPackagingTask.java     |  5 ++-
 .../maven/plugins/war/AbstractWarMojoTest.java     |  2 -
 .../org/apache/maven/plugins/war/WarMojoTest.java  | 51 +++++++++++-----------
 .../apache/maven/plugins/war/util/PathSetTest.java |  1 -
 6 files changed, 35 insertions(+), 38 deletions(-)

diff --git a/pom.xml b/pom.xml
index a47aaab..f1460d9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -148,7 +148,7 @@
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
-      <version>4.11</version>
+      <version>4.13</version>
       <scope>test</scope>
     </dependency>
 
diff --git a/src/main/java/org/apache/maven/plugins/war/overlay/OverlayManager.java b/src/main/java/org/apache/maven/plugins/war/overlay/OverlayManager.java
index 318ec68..cf83d5e 100644
--- a/src/main/java/org/apache/maven/plugins/war/overlay/OverlayManager.java
+++ b/src/main/java/org/apache/maven/plugins/war/overlay/OverlayManager.java
@@ -23,13 +23,13 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.ListIterator;
+import java.util.Objects;
 import java.util.Set;
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
 import org.apache.maven.plugins.war.Overlay;
 import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.util.StringUtils;
 
 /**
  * Manages the overlays.
@@ -222,12 +222,12 @@ public class OverlayManager
      */
     private boolean compareOverlayWithArtifact( Overlay overlay, Artifact artifact )
     {
-        return ( StringUtils.equals( overlay.getGroupId(), artifact.getGroupId() )
-            && StringUtils.equals( overlay.getArtifactId(), artifact.getArtifactId() )
-            && StringUtils.equals( overlay.getType(), artifact.getType() )
+        return ( Objects.equals( overlay.getGroupId(), artifact.getGroupId() )
+            && Objects.equals( overlay.getArtifactId(), artifact.getArtifactId() )
+            && Objects.equals( overlay.getType(), artifact.getType() )
         // MWAR-241 Make sure to treat null and "" as equal when comparing the classifier
-        && StringUtils.equals( StringUtils.defaultString( overlay.getClassifier() ),
-                               StringUtils.defaultString( artifact.getClassifier() ) ) );
+        && Objects.equals( Objects.toString( overlay.getClassifier() ),
+                           Objects.toString( artifact.getClassifier() ) ) );
     }
 
     /**
diff --git a/src/main/java/org/apache/maven/plugins/war/packaging/WarProjectPackagingTask.java b/src/main/java/org/apache/maven/plugins/war/packaging/WarProjectPackagingTask.java
index a628144..e8ccb5b 100644
--- a/src/main/java/org/apache/maven/plugins/war/packaging/WarProjectPackagingTask.java
+++ b/src/main/java/org/apache/maven/plugins/war/packaging/WarProjectPackagingTask.java
@@ -21,6 +21,7 @@ package org.apache.maven.plugins.war.packaging;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.Objects;
 
 import org.apache.maven.model.Resource;
 import org.apache.maven.plugin.MojoExecutionException;
@@ -332,8 +333,8 @@ public class WarProjectPackagingTask
                 // MWAR-129 if targetPath is only a dot <targetPath>.</targetPath> or ./
                 // and the Resource is in a part of the warSourceDirectory the file from sources will override this
                 // that's we don't have to add the targetPath yep not nice but works
-                if ( !StringUtils.equals( ".", resource.getTargetPath() )
-                    && !StringUtils.equals( "./", resource.getTargetPath() ) )
+                if ( !Objects.equals( ".", resource.getTargetPath() )
+                    && !Objects.equals( "./", resource.getTargetPath() ) )
                 {
                     targetFileName = resource.getTargetPath() + File.separator + targetFileName;
                 }
diff --git a/src/test/java/org/apache/maven/plugins/war/AbstractWarMojoTest.java b/src/test/java/org/apache/maven/plugins/war/AbstractWarMojoTest.java
index 3111696..87344ad 100644
--- a/src/test/java/org/apache/maven/plugins/war/AbstractWarMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/war/AbstractWarMojoTest.java
@@ -308,8 +308,6 @@ public abstract class AbstractWarMojoTest
 
             Archiver archiver = new JarArchiver();
 
-            archiver.setUseJvmChmod( true );
-
             archiver.setDestFile( destinationFile );
             archiver.addDirectory( directory );
 
diff --git a/src/test/java/org/apache/maven/plugins/war/WarMojoTest.java b/src/test/java/org/apache/maven/plugins/war/WarMojoTest.java
index 5696965..7a313ec 100644
--- a/src/test/java/org/apache/maven/plugins/war/WarMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/war/WarMojoTest.java
@@ -500,37 +500,36 @@ public class WarMojoTest
 
         assertTrue( "war file not created: " + expectedJarFile.toString(), expectedJarFile.exists() );
         final Map<String, JarEntry> jarContent = new HashMap<>();
-        final JarFile jarFile = new JarFile( expectedJarFile );
-
-        JarEntry entry;
-        Enumeration<JarEntry> enumeration = jarFile.entries();
-        while ( enumeration.hasMoreElements() )
-        {
-            entry = enumeration.nextElement();
-            Object previousValue = jarContent.put( entry.getName(), entry );
-            assertNull( "Duplicate Entry in Jar File: " + entry.getName(), previousValue );
-        }
-
-        for ( int i = 0; i < files.length; i++ )
-        {
-            String file = files[i];
-
-            assertTrue( "File[" + file + "] not found in archive", jarContent.containsKey( file ) );
-            if ( filesContent[i] != null )
+        try ( JarFile jarFile = new JarFile( expectedJarFile ) ) {
+            Enumeration<JarEntry> enumeration = jarFile.entries();
+            while ( enumeration.hasMoreElements() )
             {
-                assertEquals( "Content of file[" + file + "] does not match", filesContent[i],
-                              IOUtil.toString( jarFile.getInputStream( jarContent.get( file ) ) ) );
+                JarEntry entry = enumeration.nextElement();
+                Object previousValue = jarContent.put( entry.getName(), entry );
+                assertNull( "Duplicate Entry in Jar File: " + entry.getName(), previousValue );
             }
-        }
-        if ( mustNotBeInJar != null )
-        {
-            for ( String file : mustNotBeInJar )
+    
+            for ( int i = 0; i < files.length; i++ )
             {
-                assertFalse( "File[" + file + "]  found in archive", jarContent.containsKey( file ) );
-
+                String file = files[i];
+    
+                assertTrue( "File[" + file + "] not found in archive", jarContent.containsKey( file ) );
+                if ( filesContent[i] != null )
+                {
+                    assertEquals( "Content of file[" + file + "] does not match", filesContent[i],
+                                  IOUtil.toString( jarFile.getInputStream( jarContent.get( file ) ) ) );
+                }
+            }
+            if ( mustNotBeInJar != null )
+            {
+                for ( String file : mustNotBeInJar )
+                {
+                    assertFalse( "File[" + file + "]  found in archive", jarContent.containsKey( file ) );
+    
+                }
             }
+            return jarContent;
         }
-        return jarContent;
     }
 
 }
diff --git a/src/test/java/org/apache/maven/plugins/war/util/PathSetTest.java b/src/test/java/org/apache/maven/plugins/war/util/PathSetTest.java
index 2ccfc6b..6375109 100644
--- a/src/test/java/org/apache/maven/plugins/war/util/PathSetTest.java
+++ b/src/test/java/org/apache/maven/plugins/war/util/PathSetTest.java
@@ -26,7 +26,6 @@ import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
 import java.io.IOException;
-import java.nio.file.Path;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;