hadoop-common-commits mailing list archives

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

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

Modified: hadoop/core/branches/branch-0.19/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.19/CHANGES.txt?rev=770550&r1=770549&r2=770550&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.19/CHANGES.txt (original)
+++ hadoop/core/branches/branch-0.19/CHANGES.txt Fri May  1 06:46:37 2009
@@ -104,6 +104,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 
 
     HADOOP-5225. Workaround for tmp file handling in HDFS. sync() is 

Modified: hadoop/core/branches/branch-0.19/src/core/org/apache/hadoop/io/compress/BZip2Codec.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.19/src/core/org/apache/hadoop/io/compress/BZip2Codec.java?rev=770550&r1=770549&r2=770550&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.19/src/core/org/apache/hadoop/io/compress/BZip2Codec.java
(original)
+++ hadoop/core/branches/branch-0.19/src/core/org/apache/hadoop/io/compress/BZip2Codec.java
Fri May  1 06:46:37 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.19/src/test/org/apache/hadoop/io/compress/TestCodec.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/io/compress/TestCodec.java?rev=770550&r1=770549&r2=770550&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/io/compress/TestCodec.java
(original)
+++ hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/io/compress/TestCodec.java
Fri May  1 06:46:37 2009
@@ -52,26 +52,31 @@
   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 testLzoCodec() throws IOException {
     if (LzoCodec.isNativeLzoLoaded(conf)) {
+      codecTest(conf, seed, 0, "org.apache.hadoop.io.compress.LzoCodec");
       codecTest(conf, seed, count, "org.apache.hadoop.io.compress.LzoCodec");
     }
   }
   
   public void testLzopCodec() throws IOException {
     if (LzopCodec.isNativeLzoLoaded(conf)) {
+      codecTest(conf, seed, 0, "org.apache.hadoop.io.compress.LzopCodec");
       codecTest(conf, seed, count, "org.apache.hadoop.io.compress.LzopCodec");
     }
   }
   
   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");    
   }
 
@@ -150,8 +155,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