You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2013/01/20 20:32:30 UTC
svn commit: r1435925 - in /commons/proper/compress/trunk/src: changes/
main/java/org/apache/commons/compress/archivers/dump/
test/java/org/apache/commons/compress/archivers/dump/ test/resources/
Author: bodewig
Date: Sun Jan 20 19:32:30 2013
New Revision: 1435925
URL: http://svn.apache.org/viewvc?rev=1435925&view=rev
Log:
Don't close dump's input when the archive has been consumed
Added:
commons/proper/compress/trunk/src/test/resources/archive_with_trailer.dump
- copied, changed from r1435891, commons/proper/compress/trunk/src/test/resources/bla.dump
Modified:
commons/proper/compress/trunk/src/changes/changes.xml
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStream.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStreamTest.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=1435925&r1=1435924&r2=1435925&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Sun Jan 20 19:32:30 2013
@@ -138,6 +138,11 @@ The <action> type attribute can be add,u
TarArchiveInputStream could leave the second EOF record
inside the stream it had just finished reading.
</action>
+ <action type="fix" date="2013-01-20">
+ DumpArchiveInputStream no longer implicitly closes the
+ original input stream when it reaches the end of the
+ archive.
+ </action>
</release>
<release version="1.4.1" date="2012-05-23"
description="Release 1.4.1">
Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStream.java?rev=1435925&r1=1435924&r2=1435925&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStream.java (original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStream.java Sun Jan 20 19:32:30 2013
@@ -250,8 +250,6 @@ public class DumpArchiveInputStream exte
// check if this is an end-of-volume marker.
if (DumpArchiveConstants.SEGMENT_TYPE.END == active.getHeaderType()) {
hasHitEOF = true;
- isClosed = true;
- raw.close();
return null;
}
@@ -436,7 +434,7 @@ public class DumpArchiveInputStream exte
public int read(byte[] buf, int off, int len) throws IOException {
int totalRead = 0;
- if (isClosed || (entryOffset >= entrySize)) {
+ if (hasHitEOF || isClosed || (entryOffset >= entrySize)) {
return -1;
}
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStreamTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStreamTest.java?rev=1435925&r1=1435924&r2=1435925&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStreamTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStreamTest.java Sun Jan 20 19:32:30 2013
@@ -18,7 +18,10 @@
*/
package org.apache.commons.compress.archivers.dump;
+import static org.junit.Assert.assertArrayEquals;
+
import java.io.FileInputStream;
+import java.io.InputStream;
import org.apache.commons.compress.AbstractTestCase;
import org.apache.commons.compress.archivers.ArchiveException;
@@ -51,4 +54,20 @@ public class DumpArchiveInputStreamTest
}
}
+ public void testConsumesArchiveCompletely() throws Exception {
+ InputStream is = DumpArchiveInputStreamTest.class
+ .getResourceAsStream("/archive_with_trailer.dump");
+ DumpArchiveInputStream dump = new DumpArchiveInputStream(is);
+ while (dump.getNextDumpEntry() != null) {
+ // just consume the archive
+ ;
+ }
+ byte[] expected = new byte[] {
+ 'H', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd', '!', '\n'
+ };
+ byte[] actual = new byte[expected.length];
+ is.read(actual);
+ assertArrayEquals(expected, actual);
+ }
+
}
Copied: commons/proper/compress/trunk/src/test/resources/archive_with_trailer.dump (from r1435891, commons/proper/compress/trunk/src/test/resources/bla.dump)
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/resources/archive_with_trailer.dump?p2=commons/proper/compress/trunk/src/test/resources/archive_with_trailer.dump&p1=commons/proper/compress/trunk/src/test/resources/bla.dump&r1=1435891&r2=1435925&rev=1435925&view=diff
==============================================================================
Binary files - no diff available.