harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jessewil...@apache.org
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 GMT
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();



Mime
View raw message