Author: bodewig
Date: Fri Feb 21 14:21:12 2014
New Revision: 1570582

URL: http://svn.apache.org/r1570582
Log:
COMPRESS-264 make sure the very first read operation actually fills the 
ByteBuffer

Modified:
    commons/proper/compress/trunk/src/changes/changes.xml
    
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
    
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
    
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1570582&r1=1570581&r2=1570582&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Fri Feb 21 14:21:12 
2014
@@ -67,6 +67,11 @@ The <action> type attribute can be add,u
         implementations that encode big numbers by not adding a
         trailing NUL.
       </action>
+      <action issue="COMPRESS-264" type="fix" date="2014-02-21">
+        ZipArchiveInputStream would return NUL bytes for the first 512
+        bytes of a STORED entry if it was the very first entry of the
+        archive.
+      </action>
     </release>
     <release version="1.7" date="2014-01-20"
              description="Release 1.7">

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java?rev=1570582&r1=1570581&r2=1570582&view=diff
==============================================================================
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
 Fri Feb 21 14:21:12 2014
@@ -180,6 +180,8 @@ public class ZipArchiveInputStream exten
         in = new PushbackInputStream(inputStream, buf.capacity());
         this.allowStoredEntriesWithDataDescriptor =
             allowStoredEntriesWithDataDescriptor;
+        // haven't read anything so far
+        buf.limit(0);
     }
 
     public ZipArchiveEntry getNextZipEntry() throws IOException {

Modified: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java?rev=1570582&r1=1570581&r2=1570582&view=diff
==============================================================================
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
 (original)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
 Fri Feb 21 14:21:12 2014
@@ -156,8 +156,8 @@ public class ZipArchiveInputStreamTest {
      * <a href="https://issues.apache.org/jira/browse/COMPRESS-264";
      * >COMPRESS-264</a>.
      */
-    //@Test
-    public void testCompress264() throws Exception {
+    @Test
+    public void testReadingOfFirstStoredEntry() throws Exception {
         ZipArchiveInputStream in = new ZipArchiveInputStream(new 
FileInputStream(getFile("COMPRESS-264.zip")));
         
         try {

Modified: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java?rev=1570582&r1=1570581&r2=1570582&view=diff
==============================================================================
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
 (original)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
 Fri Feb 21 14:21:12 2014
@@ -263,7 +263,7 @@ public class ZipFileTest extends TestCas
      * <a href="https://issues.apache.org/jira/browse/COMPRESS-264";
      * >COMPRESS-264</a>.
      */
-    public void testCompress264() throws Exception {
+    public void testReadingOfFirstStoredEntry() throws Exception {
         File archive = getFile("COMPRESS-264.zip");
         zf = new ZipFile(archive);
         ZipArchiveEntry ze = zf.getEntry("test.txt");


Reply via email to