Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 25547 invoked from network); 23 Nov 2009 16:37:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 23 Nov 2009 16:37:38 -0000 Received: (qmail 1068 invoked by uid 500); 23 Nov 2009 16:37:38 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 1032 invoked by uid 500); 23 Nov 2009 16:37:38 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 1023 invoked by uid 99); 23 Nov 2009 16:37:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Nov 2009 16:37:38 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Nov 2009 16:37:35 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B5DA723888E8; Mon, 23 Nov 2009 16:37:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r883400 - in /harmony/enhanced/classlib/trunk/modules/archive/src: main/java/java/util/zip/ test/java/org/apache/harmony/archive/tests/java/util/zip/ Date: Mon, 23 Nov 2009 16:37:13 -0000 To: commits@harmony.apache.org From: jessewilson@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091123163713.B5DA723888E8@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jessewilson Date: Mon Nov 23 16:37:13 2009 New Revision: 883400 URL: http://svn.apache.org/viewvc?rev=883400&view=rev Log: Rolling back 882798: Implementing DeflaterOutputStream.flush(). The change broke our Pack200 tests. Modified: harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Deflater.java harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/DeflaterOutputStream.java harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterOutputStreamTest.java harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/GZIPOutputStreamTest.java harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipOutputStreamTest.java Modified: harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Deflater.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Deflater.java?rev=883400&r1=883399&r2=883400&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Deflater.java (original) +++ harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Deflater.java Mon Nov 23 16:37:13 2009 @@ -75,21 +75,9 @@ */ public static final int NO_COMPRESSION = 0; - /** - * Use buffering for best compression. - */ - static final int Z_NO_FLUSH = 0; + private static final int Z_NO_FLUSH = 0; - /** - * Flush buffers so recipients can immediately decode the data sent thus - * far. This mode may degrade compression. - */ - static final int Z_SYNC_FLUSH = 2; - - /** - * Flush buffers because there is no further data. - */ - static final int Z_FINISH = 4; + private static final int Z_FINISH = 4; // Fill in the JNI id caches private static native void oneTimeInitialization(); @@ -186,31 +174,24 @@ * maximum number of bytes of compressed data to be written. * @return the number of bytes of compressed data written to {@code buf}. */ - public int deflate(byte[] buf, int off, int nbytes) { - return deflate(buf, off, nbytes, flushParm); - } - - /** - * @param flushParam one of {@link #Z_NO_FLUSH}, {@link #Z_FINISH} or - * {@link #Z_SYNC_FLUSH}. - */ - synchronized int deflate(byte[] buf, int off, int nbytes, int flushParam) { + public synchronized int deflate(byte[] buf, int off, int nbytes) { if (streamHandle == -1) { throw new IllegalStateException(); } // avoid int overflow, check null buf - if (off > buf.length || nbytes < 0 || off < 0 || buf.length - off < nbytes) { - throw new ArrayIndexOutOfBoundsException(); - } - // put a stub buffer, no effect. - if (inputBuffer == null) { - setInput(STUB_INPUT_BUFFER); + if (off <= buf.length && nbytes >= 0 && off >= 0 + && buf.length - off >= nbytes) { + // put a stub buffer, no effect. + if (null == inputBuffer) { + setInput(STUB_INPUT_BUFFER); + } + return deflateImpl(buf, off, nbytes, streamHandle, flushParm); } - return deflateImpl(buf, off, nbytes, streamHandle, flushParam); + throw new ArrayIndexOutOfBoundsException(); } private synchronized native int deflateImpl(byte[] buf, int off, - int nbytes, long handle, int flushParm); + int nbytes, long handle, int flushParm1); private synchronized native void endImpl(long handle); Modified: harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/DeflaterOutputStream.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/DeflaterOutputStream.java?rev=883400&r1=883399&r2=883400&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/DeflaterOutputStream.java (original) +++ harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/DeflaterOutputStream.java Mon Nov 23 16:37:13 2009 @@ -115,19 +115,6 @@ } /** - * Writes any unwritten compressed data to the underlying stream and flushes - * the underlying stream. - * - * @throws IOException - * If an error occurs during writing. - */ - @Override public void flush() throws IOException { - int count = def.deflate(buf, 0, buf.length, Deflater.Z_SYNC_FLUSH); - out.write(buf, 0, count); - out.flush(); - } - - /** * Writes any unwritten compressed data to the underlying stream, the closes * all underlying streams. This stream can no longer be used after close() * has been called. Modified: harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterOutputStreamTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterOutputStreamTest.java?rev=883400&r1=883399&r2=883400&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterOutputStreamTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterOutputStreamTest.java Mon Nov 23 16:37:13 2009 @@ -23,8 +23,6 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; -import java.io.PipedInputStream; -import java.io.PipedOutputStream; import java.util.zip.Deflater; import java.util.zip.DeflaterOutputStream; import java.util.zip.InflaterInputStream; @@ -401,19 +399,4 @@ assertTrue(dos.getDaflateFlag()); dos.close(); } - - public void testFlush() throws IOException { - PipedOutputStream pout = new PipedOutputStream(); - PipedInputStream pin = new PipedInputStream(pout); - DeflaterOutputStream out = new DeflaterOutputStream(pout); - InflaterInputStream in = new InflaterInputStream(pin); - - out.write(1); - out.write(2); - out.write(3); - out.flush(); - assertEquals(1, in.read()); // without flush, this blocks forever!! - assertEquals(2, in.read()); - assertEquals(3, in.read()); - } } Modified: harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/GZIPOutputStreamTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/GZIPOutputStreamTest.java?rev=883400&r1=883399&r2=883400&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/GZIPOutputStreamTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/GZIPOutputStreamTest.java Mon Nov 23 16:37:13 2009 @@ -20,13 +20,8 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; -import java.io.PipedInputStream; -import java.io.PipedOutputStream; import java.util.zip.Checksum; -import java.util.zip.DeflaterOutputStream; -import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; -import java.util.zip.InflaterInputStream; public class GZIPOutputStreamTest extends junit.framework.TestCase { @@ -163,21 +158,6 @@ } } - public void testFlush() throws IOException { - PipedOutputStream pout = new PipedOutputStream(); - PipedInputStream pin = new PipedInputStream(pout); - GZIPOutputStream out = new GZIPOutputStream(pout); - GZIPInputStream in = new GZIPInputStream(pin); - - out.write(1); - out.write(2); - out.write(3); - out.flush(); - assertEquals(1, in.read()); // without flush, this blocks forever!! - assertEquals(2, in.read()); - assertEquals(3, in.read()); - } - @Override protected void setUp() { } Modified: harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipOutputStreamTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipOutputStreamTest.java?rev=883400&r1=883399&r2=883400&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipOutputStreamTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipOutputStreamTest.java Mon Nov 23 16:37:13 2009 @@ -21,8 +21,6 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; -import java.io.PipedInputStream; -import java.io.PipedOutputStream; import java.util.zip.CRC32; import java.util.zip.ZipEntry; import java.util.zip.ZipException; @@ -271,23 +269,6 @@ zip1.close(); } - public void testFlush() throws IOException { - PipedOutputStream pout = new PipedOutputStream(); - PipedInputStream pin = new PipedInputStream(pout); - ZipOutputStream out = new ZipOutputStream(pout); - ZipInputStream in = new ZipInputStream(pin); - out.putNextEntry(new ZipEntry("foo.txt")); - - out.write(1); - out.write(2); - out.write(3); - out.flush(); - assertEquals("foo.txt", in.getNextEntry().getName()); - assertEquals(1, in.read()); // without flush, this blocks forever!! - assertEquals(2, in.read()); - assertEquals(3, in.read()); - } - @Override protected void setUp() throws Exception { super.setUp();