harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r1003513 - in /harmony/enhanced/java/trunk/classlib/modules/archive/src: main/java/java/util/zip/Inflater.java test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterTest.java
Date Fri, 01 Oct 2010 12:46:51 GMT
Author: tellison
Date: Fri Oct  1 12:46:51 2010
New Revision: 1003513

URL: http://svn.apache.org/viewvc?rev=1003513&view=rev
Log:
Apply fix for HARMONY-6637 ([classlib] [archive] Inflater.inflate() short-circuits on zero-length
request, finished() never true for a zero-length data source)

Modified:
    harmony/enhanced/java/trunk/classlib/modules/archive/src/main/java/java/util/zip/Inflater.java
    harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterTest.java

Modified: harmony/enhanced/java/trunk/classlib/modules/archive/src/main/java/java/util/zip/Inflater.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/archive/src/main/java/java/util/zip/Inflater.java?rev=1003513&r1=1003512&r2=1003513&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/archive/src/main/java/java/util/zip/Inflater.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/archive/src/main/java/java/util/zip/Inflater.java
Fri Oct  1 12:46:51 2010
@@ -236,10 +236,6 @@ public class Inflater {
             throw new ArrayIndexOutOfBoundsException();
         }
 
-        if (nbytes == 0) {
-            return 0;
-        }
-
         if (streamHandle == -1) {
             throw new IllegalStateException();
         }

Modified: harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterTest.java?rev=1003513&r1=1003512&r2=1003513&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterTest.java
Fri Oct  1 12:46:51 2010
@@ -17,13 +17,14 @@
 package org.apache.harmony.archive.tests.java.util.zip;
 
 import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
-import java.util.Arrays;
-import java.util.zip.Adler32;
 import java.io.UnsupportedEncodingException;
+import java.util.zip.Adler32;
 import java.util.zip.DataFormatException;
 import java.util.zip.Deflater;
+import java.util.zip.DeflaterOutputStream;
 import java.util.zip.Inflater;
 import java.util.zip.ZipException;
 
@@ -448,6 +449,28 @@ public class InflaterTest extends junit.
         infl2.end();
     }
 
+    /*
+     * Regression test for HARMONY-6637
+     */
+    public void testInflateZero() throws Exception {
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        DeflaterOutputStream deflaterOutputStream = new DeflaterOutputStream(
+                byteArrayOutputStream);
+        deflaterOutputStream.close();
+        byte[] input = byteArrayOutputStream.toByteArray();
+
+        Inflater inflater = new Inflater();
+        inflater.setInput(input);
+        byte[] buffer = new byte[0];
+        int numRead = 0;
+        while (!inflater.finished()) {
+            int inflatedChunkSize = inflater.inflate(buffer, numRead,
+                    buffer.length - numRead);
+            numRead += inflatedChunkSize;
+        }
+        inflater.end();
+    }
+
 	/**
 	 * @tests java.util.zip.Inflater#Inflater()
 	 */



Mime
View raw message