From d13027731c6967326a772f141a3cdbbe9a1fa79b Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Mon, 4 Aug 2003 12:11:37 +0000 Subject: [PATCH] Only calculate the CRC of STORED entries in if absolutely necessary. PR: 21899 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275010 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 3 ++ docs/external.html | 37 +++++++++++++++++++ src/etc/testcases/taskdefs/unzip.xml | 6 +++ src/etc/testcases/taskdefs/zip.xml | 6 +++ .../org/apache/tools/ant/taskdefs/Zip.java | 8 +--- .../org/apache/tools/zip/ZipOutputStream.java | 24 +++++++++--- .../apache/tools/ant/taskdefs/UnzipTest.java | 7 ++++ 7 files changed, 80 insertions(+), 11 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index 919c1d2de..0313f28d9 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -548,6 +548,9 @@ If set to true, the process will be spawned. Bugzilla Report 5907. to throw an exception if any thread fails without waiting for all other threads to complete. +* and friends will consume far less memory than they used to + when run with compress="false". Bugzilla Report 21899. + Changes from Ant 1.5.2 to Ant 1.5.3 =================================== diff --git a/docs/external.html b/docs/external.html index 0bba10dcb..6551d7f87 100644 --- a/docs/external.html +++ b/docs/external.html @@ -3891,6 +3891,43 @@ valign="top" align="left"> Commercial + + +

+ + Zelix KlassMaster Java Obfuscator +

+

The task ZKMTask allows the Zelix KlassMaster Java obfuscator to be integrated into an Ant build.

+ + + + + + + + + + + +
+ Compatibility: + + Ant 1.4.1 +
+ URL: + + Zelix KlassMaster Ant Task +
+ License: + + Commercial +
diff --git a/src/etc/testcases/taskdefs/unzip.xml b/src/etc/testcases/taskdefs/unzip.xml index 9b979f6e0..1fcc4d881 100644 --- a/src/etc/testcases/taskdefs/unzip.xml +++ b/src/etc/testcases/taskdefs/unzip.xml @@ -27,6 +27,12 @@ + + + + + + diff --git a/src/etc/testcases/taskdefs/zip.xml b/src/etc/testcases/taskdefs/zip.xml index 06ec49ccc..db44f2131 100644 --- a/src/etc/testcases/taskdefs/zip.xml +++ b/src/etc/testcases/taskdefs/zip.xml @@ -55,6 +55,12 @@ includes="asf-logo.gif" /> + + + + diff --git a/src/main/org/apache/tools/ant/taskdefs/Zip.java b/src/main/org/apache/tools/ant/taskdefs/Zip.java index 8485c30c6..abda0f44c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Zip.java +++ b/src/main/org/apache/tools/ant/taskdefs/Zip.java @@ -977,15 +977,11 @@ public class Zip extends MatchingTask { /* * ZipOutputStream.putNextEntry expects the ZipEntry to * know its size and the CRC sum before you start writing - * the data when using STORED mode. + * the data when using STORED mode - unless it is seekable. * * This forces us to process the data twice. - * - * In DEFLATED mode, it will take advantage of a Zip - * Version 2 feature where size can be stored after the - * data (as the data itself signals end of data). */ - if (!doCompress) { + if (!zOut.isSeekable() && !doCompress) { long size = 0; CRC32 cal = new CRC32(); if (!in.markSupported()) { diff --git a/src/main/org/apache/tools/zip/ZipOutputStream.java b/src/main/org/apache/tools/zip/ZipOutputStream.java index 4b30c1a36..213186fde 100644 --- a/src/main/org/apache/tools/zip/ZipOutputStream.java +++ b/src/main/org/apache/tools/zip/ZipOutputStream.java @@ -80,12 +80,12 @@ import java.util.zip.ZipException; * file.

* *

If RandomAccessFile cannot be used, this implementation will use - * a Data Descriptor to store size and - * CRC information for DEFLATED entries, this means, you don't need to + * a Data Descriptor to store size and CRC information for {@link + * #DEFLATED DEFLATED} entries, this means, you don't need to * calculate them yourself. Unfortunately this is not possible for - * the STORED method, here setting the CRC and uncompressed size - * information is required before {@link #putNextEntry putNextEntry} - * will be called.

+ * the {@link #STORED STORED} method, here setting the CRC and + * uncompressed size information is required before {@link + * #putNextEntry putNextEntry} can be called.

* * @author Stefan Bodewig * @author Richard Evans @@ -290,6 +290,20 @@ public class ZipOutputStream extends FilterOutputStream { } } + /** + * Is this archive writing to a seekable stream (i.e. a random + * access file)? + * + *

For seekable streams, you don't need to calculate the CRC or + * uncompressed size for {@link #STORED STORED} entries before + * invoking {@link #putEntry putEntry}. + * + * @since 1.17 + */ + public boolean isSeekable() { + return raf != null; + } + /** * The encoding to use for filenames and the file comment. * diff --git a/src/testcases/org/apache/tools/ant/taskdefs/UnzipTest.java b/src/testcases/org/apache/tools/ant/taskdefs/UnzipTest.java index 09f0fee4b..a9a01e790 100644 --- a/src/testcases/org/apache/tools/ant/taskdefs/UnzipTest.java +++ b/src/testcases/org/apache/tools/ant/taskdefs/UnzipTest.java @@ -101,6 +101,13 @@ public class UnzipTest extends BuildFileTest { project.resolveFile("asf-logo.gif"))); } + public void testTestUncompressedZipTask() throws java.io.IOException { + FileUtils fileUtils = FileUtils.newFileUtils(); + executeTarget("testUncompressedZipTask"); + assertTrue(fileUtils.contentEquals(project.resolveFile("../asf-logo.gif"), + project.resolveFile("asf-logo.gif"))); + } + /* * PR 11100 */