Return-Path: Delivered-To: apmail-hadoop-core-commits-archive@www.apache.org Received: (qmail 5777 invoked from network); 1 May 2009 06:35:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 1 May 2009 06:35:46 -0000 Received: (qmail 14444 invoked by uid 500); 1 May 2009 06:35:46 -0000 Delivered-To: apmail-hadoop-core-commits-archive@hadoop.apache.org Received: (qmail 14379 invoked by uid 500); 1 May 2009 06:35:45 -0000 Mailing-List: contact core-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: core-dev@hadoop.apache.org Delivered-To: mailing list core-commits@hadoop.apache.org Received: (qmail 14370 invoked by uid 99); 1 May 2009 06:35:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 May 2009 06:35:45 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.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, 01 May 2009 06:35:44 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 7BF6723888E7; Fri, 1 May 2009 06:35:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r770549 - in /hadoop/core/trunk: CHANGES.txt src/core/org/apache/hadoop/io/compress/BZip2Codec.java src/test/org/apache/hadoop/io/compress/TestCodec.java Date: Fri, 01 May 2009 06:35:24 -0000 To: core-commits@hadoop.apache.org From: dhruba@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090501063524.7BF6723888E7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dhruba Date: Fri May 1 06:35:23 2009 New Revision: 770549 URL: http://svn.apache.org/viewvc?rev=770549&view=rev Log: HADOOP-5213. Fix Null pointer exception caused when bzip2compression was used and user closed a output stream without writing any data. (Zheng Shao via dhruba) Modified: hadoop/core/trunk/CHANGES.txt hadoop/core/trunk/src/core/org/apache/hadoop/io/compress/BZip2Codec.java hadoop/core/trunk/src/test/org/apache/hadoop/io/compress/TestCodec.java Modified: hadoop/core/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=770549&r1=770548&r2=770549&view=diff ============================================================================== --- hadoop/core/trunk/CHANGES.txt (original) +++ hadoop/core/trunk/CHANGES.txt Fri May 1 06:35:23 2009 @@ -1431,6 +1431,10 @@ HADOOP-5671. Fix FNF exceptions when copying from old versions of HftpFileSystem. (Tsz Wo (Nicholas), SZE via cdouglas) + HADOOP-5213. Fix Null pointer exception caused when bzip2compression + was used and user closed a output stream without writing any data. + (Zheng Shao via dhruba) + Release 0.19.1 - 2009-02-23 IMPROVEMENTS Modified: hadoop/core/trunk/src/core/org/apache/hadoop/io/compress/BZip2Codec.java URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/core/org/apache/hadoop/io/compress/BZip2Codec.java?rev=770549&r1=770548&r2=770549&view=diff ============================================================================== --- hadoop/core/trunk/src/core/org/apache/hadoop/io/compress/BZip2Codec.java (original) +++ hadoop/core/trunk/src/core/org/apache/hadoop/io/compress/BZip2Codec.java Fri May 1 06:35:23 2009 @@ -169,6 +169,12 @@ } public void finish() throws IOException { + if (needsReset) { + // In the case that nothing is written to this stream, we still need to + // write out the header before closing, otherwise the stream won't be + // recognized by BZip2CompressionInputStream. + internalReset(); + } this.output.finish(); needsReset = true; } @@ -202,6 +208,12 @@ } public void close() throws IOException { + if (needsReset) { + // In the case that nothing is written to this stream, we still need to + // write out the header before closing, otherwise the stream won't be + // recognized by BZip2CompressionInputStream. + internalReset(); + } this.output.flush(); this.output.close(); needsReset = true; Modified: hadoop/core/trunk/src/test/org/apache/hadoop/io/compress/TestCodec.java URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/io/compress/TestCodec.java?rev=770549&r1=770548&r2=770549&view=diff ============================================================================== --- hadoop/core/trunk/src/test/org/apache/hadoop/io/compress/TestCodec.java (original) +++ hadoop/core/trunk/src/test/org/apache/hadoop/io/compress/TestCodec.java Fri May 1 06:35:23 2009 @@ -53,15 +53,18 @@ private int seed = new Random().nextInt(); public void testDefaultCodec() throws IOException { + codecTest(conf, seed, 0, "org.apache.hadoop.io.compress.DefaultCodec"); codecTest(conf, seed, count, "org.apache.hadoop.io.compress.DefaultCodec"); } public void testGzipCodec() throws IOException { + codecTest(conf, seed, 0, "org.apache.hadoop.io.compress.GzipCodec"); codecTest(conf, seed, count, "org.apache.hadoop.io.compress.GzipCodec"); } - public void testBZip2Codec() throws IOException { - codecTest(conf, seed, count, "org.apache.hadoop.io.compress.BZip2Codec"); + public void testBZip2Codec() throws IOException { + codecTest(conf, seed, 0, "org.apache.hadoop.io.compress.BZip2Codec"); + codecTest(conf, seed, count, "org.apache.hadoop.io.compress.BZip2Codec"); } private static void codecTest(Configuration conf, int seed, int count, @@ -154,8 +157,9 @@ public void testSequenceFileBZip2Codec() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException { - sequenceFileCodecTest(conf, 100, "org.apache.hadoop.io.compress.BZip2Codec", 100); - sequenceFileCodecTest(conf, 200000, "org.apache.hadoop.io.compress.BZip2Codec", 1000000); + sequenceFileCodecTest(conf, 0, "org.apache.hadoop.io.compress.BZip2Codec", 100); + sequenceFileCodecTest(conf, 100, "org.apache.hadoop.io.compress.BZip2Codec", 100); + sequenceFileCodecTest(conf, 200000, "org.apache.hadoop.io.compress.BZip2Codec", 1000000); } private static void sequenceFileCodecTest(Configuration conf, int lines,