commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1653370 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
Date Tue, 20 Jan 2015 21:02:24 GMT
Author: bodewig
Date: Tue Jan 20 21:02:24 2015
New Revision: 1653370

URL: http://svn.apache.org/r1653370
Log:
Arrays.copyOf requires Java6

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java?rev=1653370&r1=1653369&r2=1653370&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
Tue Jan 20 21:02:24 2015
@@ -366,11 +366,17 @@ public class ZipArchiveEntry extends jav
     }
 
     private ZipExtraField[] copyOf(ZipExtraField[] src){
-        return Arrays.copyOf(src, src.length);
+        return copyOf(src, src.length);
+    }
+
+    private ZipExtraField[] copyOf(ZipExtraField[] src, int length) {
+        ZipExtraField[] cpy = new ZipExtraField[length];
+        System.arraycopy(src, 0, cpy, 0, Math.min(src.length, length));
+        return cpy;
     }
 
     private ZipExtraField[] getMergedFields() {
-        final ZipExtraField[] zipExtraFields = Arrays.copyOf(extraFields, extraFields.length
+ 1);
+        final ZipExtraField[] zipExtraFields = copyOf(extraFields, extraFields.length + 1);
         zipExtraFields[zipExtraFields.length] = unparseableExtra;
         return zipExtraFields;
     }
@@ -401,7 +407,7 @@ public class ZipArchiveEntry extends jav
                 if (getExtraField(ze.getHeaderId())!= null){
                     removeExtraField(ze.getHeaderId());
                 }
-                final ZipExtraField[] zipExtraFields = Arrays.copyOf(extraFields, extraFields.length
+ 1);
+                final ZipExtraField[] zipExtraFields = copyOf(extraFields, extraFields.length
+ 1);
                 zipExtraFields[zipExtraFields.length -1] = ze;
                 extraFields = zipExtraFields;
             }



Mime
View raw message