hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dhr...@apache.org
Subject svn commit: r770551 - in /hadoop/core/branches/branch-0.20: 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:50:57 GMT
Author: dhruba
Date: Fri May  1 06:50:57 2009
New Revision: 770551

URL: http://svn.apache.org/viewvc?rev=770551&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/branches/branch-0.20/CHANGES.txt
    hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/io/compress/BZip2Codec.java
    hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/io/compress/TestCodec.java

Modified: hadoop/core/branches/branch-0.20/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/CHANGES.txt?rev=770551&r1=770550&r2=770551&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/CHANGES.txt (original)
+++ hadoop/core/branches/branch-0.20/CHANGES.txt Fri May  1 06:50:57 2009
@@ -29,6 +29,10 @@
     HADOOP-5688. Fix HftpFileSystem checksum path construction. (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.20.0 - 2009-04-15
 
   INCOMPATIBLE CHANGES

Modified: hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/io/compress/BZip2Codec.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/io/compress/BZip2Codec.java?rev=770551&r1=770550&r2=770551&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/io/compress/BZip2Codec.java
(original)
+++ hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/io/compress/BZip2Codec.java
Fri May  1 06:50:57 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/branches/branch-0.20/src/test/org/apache/hadoop/io/compress/TestCodec.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/io/compress/TestCodec.java?rev=770551&r1=770550&r2=770551&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/io/compress/TestCodec.java
(original)
+++ hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/io/compress/TestCodec.java
Fri May  1 06:50:57 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, 



Mime
View raw message