Return-Path: X-Original-To: apmail-hadoop-common-commits-archive@www.apache.org Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0DD3F10150 for ; Fri, 28 Jun 2013 21:07:34 +0000 (UTC) Received: (qmail 22965 invoked by uid 500); 28 Jun 2013 21:07:33 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 22927 invoked by uid 500); 28 Jun 2013 21:07:33 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 22920 invoked by uid 99); 28 Jun 2013 21:07:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Jun 2013 21:07:33 +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; Fri, 28 Jun 2013 21:07:32 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 5858E2388900; Fri, 28 Jun 2013 21:07:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1497923 - in /hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common: ./ src/main/java/org/apache/hadoop/io/compress/ src/test/java/org/apache/hadoop/io/compress/ Date: Fri, 28 Jun 2013 21:07:13 -0000 To: common-commits@hadoop.apache.org From: acmurthy@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130628210713.5858E2388900@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: acmurthy Date: Fri Jun 28 21:07:12 2013 New Revision: 1497923 URL: http://svn.apache.org/r1497923 Log: Merge -c 1497922 from trunk to branch-2 to fix HADOOP-9665. Fixed BlockDecompressorStream#decompress to return -1 rather than throw EOF at end of file. Contributed by Zhijie Shen. Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/BlockDecompressorStream.java hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/TestBlockDecompressorStream.java Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1497923&r1=1497922&r2=1497923&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt (original) +++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt Fri Jun 28 21:07:12 2013 @@ -509,6 +509,9 @@ Release 2.1.0-beta - 2013-07-02 HADOOP-9264. Port change to use Java untar API on Windows from branch-1-win to trunk. (Chris Nauroth via suresh) + HADOOP-9665. Fixed BlockDecompressorStream#decompress to return -1 rather + than throw EOF at end of file. (Zhijie Shen via acmurthy) + Release 2.0.5-alpha - 06/06/2013 INCOMPATIBLE CHANGES Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/BlockDecompressorStream.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/BlockDecompressorStream.java?rev=1497923&r1=1497922&r2=1497923&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/BlockDecompressorStream.java (original) +++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/BlockDecompressorStream.java Fri Jun 28 21:07:12 2013 @@ -93,7 +93,13 @@ public class BlockDecompressorStream ext } } if (decompressor.needsInput()) { - int m = getCompressedData(); + int m; + try { + m = getCompressedData(); + } catch (EOFException e) { + eof = true; + return -1; + } // Send the read data to the decompressor decompressor.setInput(buffer, 0, m); } Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/TestBlockDecompressorStream.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/TestBlockDecompressorStream.java?rev=1497923&r1=1497922&r2=1497923&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/TestBlockDecompressorStream.java (original) +++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/TestBlockDecompressorStream.java Fri Jun 28 21:07:12 2013 @@ -17,14 +17,16 @@ */ package org.apache.hadoop.io.compress; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.nio.ByteBuffer; import org.apache.hadoop.conf.Configuration; - import org.junit.Test; -import static org.junit.Assert.*; public class TestBlockDecompressorStream { @@ -33,9 +35,23 @@ public class TestBlockDecompressorStream private ByteArrayOutputStream bytesOut; @Test - public void testRead() throws IOException { + public void testRead1() throws IOException { + testRead(0); + } + + @Test + public void testRead2() throws IOException { + // Test eof after getting non-zero block size info + testRead(4); + } + + private void testRead(int bufLen) throws IOException { // compress empty stream bytesOut = new ByteArrayOutputStream(); + if (bufLen > 0) { + bytesOut.write(ByteBuffer.allocate(bufLen).putInt(1024).array(), 0, + bufLen); + } BlockCompressorStream blockCompressorStream = new BlockCompressorStream(bytesOut, new FakeCompressor(), 1024, 0); @@ -44,7 +60,8 @@ public class TestBlockDecompressorStream // check compressed output buf = bytesOut.toByteArray(); - assertEquals("empty file compressed output size is not 4", 4, buf.length); + assertEquals("empty file compressed output size is not " + (bufLen + 4), + bufLen + 4, buf.length); // use compressed output as input for decompression bytesIn = new ByteArrayInputStream(buf); @@ -57,6 +74,8 @@ public class TestBlockDecompressorStream -1 , blockDecompressorStream.read()); } catch (IOException e) { fail("unexpected IOException : " + e); + } finally { + blockDecompressorStream.close(); } } }