Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E6EA8EAED for ; Sun, 20 Jan 2013 19:32:51 +0000 (UTC) Received: (qmail 76435 invoked by uid 500); 20 Jan 2013 19:32:51 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 76246 invoked by uid 500); 20 Jan 2013 19:32:51 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 76239 invoked by uid 99); 20 Jan 2013 19:32:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 20 Jan 2013 19:32:51 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.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; Sun, 20 Jan 2013 19:32:50 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 0D3A623888D2; Sun, 20 Jan 2013 19:32:31 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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/ Date: Sun, 20 Jan 2013 19:32:30 -0000 To: commits@commons.apache.org From: bodewig@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130120193231.0D3A623888D2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 type attribute can be add,u TarArchiveInputStream could leave the second EOF record inside the stream it had just finished reading. + + DumpArchiveInputStream no longer implicitly closes the + original input stream when it reaches the end of the + archive. + 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.