hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject svn commit: r1099324 - in /hadoop/common/branches/branch-0.20-security-203/src: core/org/apache/hadoop/io/compress/DoNotPool.java core/org/apache/hadoop/io/compress/zlib/BuiltInGzipDecompressor.java test/org/apache/hadoop/io/compress/TestCodec.java
Date Wed, 04 May 2011 05:16:04 GMT
Author: omalley
Date: Wed May  4 05:16:04 2011
New Revision: 1099324

URL: http://svn.apache.org/viewvc?rev=1099324&view=rev
Log:
HADOOP-7258. The Gzip codec should not return null decompressors. (omalley)

Modified:
    hadoop/common/branches/branch-0.20-security-203/src/core/org/apache/hadoop/io/compress/DoNotPool.java
    hadoop/common/branches/branch-0.20-security-203/src/core/org/apache/hadoop/io/compress/zlib/BuiltInGzipDecompressor.java
    hadoop/common/branches/branch-0.20-security-203/src/test/org/apache/hadoop/io/compress/TestCodec.java

Modified: hadoop/common/branches/branch-0.20-security-203/src/core/org/apache/hadoop/io/compress/DoNotPool.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-203/src/core/org/apache/hadoop/io/compress/DoNotPool.java?rev=1099324&r1=1099323&r2=1099324&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-203/src/core/org/apache/hadoop/io/compress/DoNotPool.java
(original)
+++ hadoop/common/branches/branch-0.20-security-203/src/core/org/apache/hadoop/io/compress/DoNotPool.java
Wed May  4 05:16:04 2011
@@ -18,14 +18,17 @@
 package org.apache.hadoop.io.compress;
 
 import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
 
 /**
  * This is a marker annotation that marks a compressor or decompressor 
  * type as not to be pooled.
  */
 @Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
 @Documented
 public @interface DoNotPool {
 

Modified: hadoop/common/branches/branch-0.20-security-203/src/core/org/apache/hadoop/io/compress/zlib/BuiltInGzipDecompressor.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-203/src/core/org/apache/hadoop/io/compress/zlib/BuiltInGzipDecompressor.java?rev=1099324&r1=1099323&r2=1099324&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-203/src/core/org/apache/hadoop/io/compress/zlib/BuiltInGzipDecompressor.java
(original)
+++ hadoop/common/branches/branch-0.20-security-203/src/core/org/apache/hadoop/io/compress/zlib/BuiltInGzipDecompressor.java
Wed May  4 05:16:04 2011
@@ -31,6 +31,7 @@ import org.apache.hadoop.io.compress.DoN
  * http://www.gzip.org/
  *
  */
+@DoNotPool
 public class BuiltInGzipDecompressor implements Decompressor {
   private static final int GZIP_MAGIC_ID = 0x8b1f;  // if read as LE short int
   private static final int GZIP_DEFLATE_METHOD = 8;
@@ -109,7 +110,6 @@ public class BuiltInGzipDecompressor imp
   /**
    * Creates a new (pure Java) gzip decompressor.
    */
-  @DoNotPool
   public BuiltInGzipDecompressor() {
     state = GzipStateLabel.HEADER_BASIC;
     crc.reset();

Modified: hadoop/common/branches/branch-0.20-security-203/src/test/org/apache/hadoop/io/compress/TestCodec.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-203/src/test/org/apache/hadoop/io/compress/TestCodec.java?rev=1099324&r1=1099323&r2=1099324&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-203/src/test/org/apache/hadoop/io/compress/TestCodec.java
(original)
+++ hadoop/common/branches/branch-0.20-security-203/src/test/org/apache/hadoop/io/compress/TestCodec.java
Wed May  4 05:16:04 2011
@@ -475,31 +475,37 @@ public class TestCodec extends TestCase 
     assertTrue("ZlibFactory returned unexpected inflator",
         zlibDecompressor instanceof BuiltInZlibInflater);
 
-    // Asking for a decompressor directly from GzipCodec should return null;
     // its createOutputStream() just wraps the existing stream in a
     // java.util.zip.GZIPOutputStream.
     CompressionCodecFactory ccf = new CompressionCodecFactory(conf);
     CompressionCodec codec = ccf.getCodec(new Path("foo.gz"));
     assertTrue("Codec for .gz file is not GzipCodec", 
                codec instanceof GzipCodec);
+
+    // make sure we don't get a null decompressor
     Decompressor codecDecompressor = codec.createDecompressor();
     if (null == codecDecompressor) {
       fail("Got null codecDecompressor");
     }
 
     // Asking the CodecPool for a decompressor for GzipCodec
-    // should return null as well.
+    // should not return null
     Decompressor poolDecompressor = CodecPool.getDecompressor(codec);
     if (null == poolDecompressor) {
-      fail("Got null poolDecompressor: " + poolDecompressor);
+      fail("Got null poolDecompressor");
     }
-    // If we then ensure that the pool is populated...
+    // return a couple decompressors
     CodecPool.returnDecompressor(zlibDecompressor);
-    // return the decompressor
     CodecPool.returnDecompressor(poolDecompressor);
     Decompressor poolDecompressor2 = CodecPool.getDecompressor(codec);
-    if (poolDecompressor == poolDecompressor2) {
-      fail("Reused gzip decompressor in pool");
+    if (poolDecompressor.getClass() == BuiltInGzipDecompressor.class) {
+      if (poolDecompressor == poolDecompressor2) {
+        fail("Reused java gzip decompressor in pool");
+      }
+    } else {
+      if (poolDecompressor != poolDecompressor2) {
+        fail("Did not reuse native gzip decompressor in pool");
+      }
     }
   }
 



Mime
View raw message