You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by an...@apache.org on 2013/01/07 00:38:10 UTC

svn commit: r1429613 - in /ant/core/trunk: CONTRIBUTORS WHATSNEW contributors.xml src/main/org/apache/tools/ant/taskdefs/Zip.java src/tests/antunit/taskdefs/zip-test.xml

Author: antoine
Date: Sun Jan  6 23:38:10 2013
New Revision: 1429613

URL: http://svn.apache.org/viewvc?rev=1429613&view=rev
Log:
PR 54026 Zip task on <mappedresources> that excludes certain files by way of the mapper results in a NullPointerException

Modified:
    ant/core/trunk/CONTRIBUTORS
    ant/core/trunk/WHATSNEW
    ant/core/trunk/contributors.xml
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Zip.java
    ant/core/trunk/src/tests/antunit/taskdefs/zip-test.xml

Modified: ant/core/trunk/CONTRIBUTORS
URL: http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?rev=1429613&r1=1429612&r2=1429613&view=diff
==============================================================================
--- ant/core/trunk/CONTRIBUTORS (original)
+++ ant/core/trunk/CONTRIBUTORS Sun Jan  6 23:38:10 2013
@@ -74,6 +74,7 @@ Dan Armbrust
 Daniel Henrique
 Daniel Ribagnac
 Daniel Spilker
+Daniel Trebbien
 Danno Ferrin
 Danny Yates
 Dante Briones

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1429613&r1=1429612&r2=1429613&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Sun Jan  6 23:38:10 2013
@@ -62,6 +62,10 @@ Fixed bugs:
  * ssh tasks prompt for kerberos username/password under Java 7
    Bugzilla Report 53437.
 
+ * Zip task on <mappedresources> that excludes certain files by way of the mapper resulted in a NullPointerException
+   Bugzilla Report 54026
+
+
 Other changes:
 --------------
 

Modified: ant/core/trunk/contributors.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/contributors.xml?rev=1429613&r1=1429612&r2=1429613&view=diff
==============================================================================
--- ant/core/trunk/contributors.xml (original)
+++ ant/core/trunk/contributors.xml Sun Jan  6 23:38:10 2013
@@ -320,6 +320,10 @@
     <last>Spilker</last>
   </name>
   <name>
+    <first>Daniel</first>
+    <last>Trebbien</last>
+  </name>
+  <name>
     <first>Danno</first>
     <last>Ferrin</last>
   </name>

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Zip.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Zip.java?rev=1429613&r1=1429612&r2=1429613&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Zip.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Zip.java Sun Jan  6 23:38:10 2013
@@ -1068,22 +1068,27 @@ public class Zip extends MatchingTask {
             return;
         }
         for (int i = 0; i < resources.length; i++) {
-            String name = resources[i].getName().replace(File.separatorChar,
-                                                         '/');
+            final Resource resource = resources[i];
+            String name = resource.getName();
+            if (name == null) {
+                continue;
+            }
+            name = name.replace(File.separatorChar, '/');
+
             if ("".equals(name)) {
                 continue;
             }
-            if (resources[i].isDirectory() && doFilesonly) {
+            if (resource.isDirectory() && doFilesonly) {
                 continue;
             }
             File base = null;
-            FileProvider fp = resources[i].as(FileProvider.class);
+            FileProvider fp = resource.as(FileProvider.class);
             if (fp != null) {
                 base = ResourceUtils.asFileResource(fp).getBaseDir();
             }
 
-            if (resources[i].isDirectory()) {
-                addDirectoryResource(resources[i], name, "", base, zOut,
+            if (resource.isDirectory()) {
+                addDirectoryResource(resource, name, "", base, zOut,
                                      ArchiveFileSet.DEFAULT_DIR_MODE,
                                      ArchiveFileSet.DEFAULT_DIR_MODE);
 
@@ -1095,7 +1100,7 @@ public class Zip extends MatchingTask {
                     File f = (fp).getFile();
                     zipFile(f, zOut, name, ArchiveFileSet.DEFAULT_FILE_MODE);
                 } else {
-                    addResource(resources[i], name, "", zOut,
+                    addResource(resource, name, "", zOut,
                                 ArchiveFileSet.DEFAULT_FILE_MODE,
                                 null, null);
                 }

Modified: ant/core/trunk/src/tests/antunit/taskdefs/zip-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/zip-test.xml?rev=1429613&r1=1429612&r2=1429613&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/zip-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/zip-test.xml Sun Jan  6 23:38:10 2013
@@ -45,6 +45,21 @@
                          actual="${output}/out/bar.txt"/>
   </target>
 
+  <target name="test-54026">
+    <mkdir dir="${input}"/>
+    <touch file="${input}/test1"/>
+    <mkdir dir="${input}/subdir"/>
+    <touch file="${input}/subdir/test2"/>
+    <zip destfile="${output}/br54026-destzip.zip">
+      <mappedresources>
+        <fileset dir="${input}"/>
+        <globmapper from="subdir/*" to="subdir.orig/*"/>
+      </mappedresources>
+    </zip>
+
+    <au:assertFileExists file="${output}/br54026-destzip.zip"/>
+  </target>
+
   <target name="testMappedClasspath">
     <mkdir dir="${input}"/>
     <mkdir dir="${output}/out"/>