hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r1595525 - in /hadoop/common/branches/branch-1: CHANGES.txt src/core/org/apache/hadoop/io/compress/bzip2/CBZip2InputStream.java
Date Sat, 17 May 2014 18:34:27 GMT
Author: sandy
Date: Sat May 17 18:34:27 2014
New Revision: 1595525

URL: http://svn.apache.org/r1595525
Log:
HADOOP-10614. CBZip2InputStream is not threadsafe (Xiangrui Meng via Sandy Ryza)

Modified:
    hadoop/common/branches/branch-1/CHANGES.txt
    hadoop/common/branches/branch-1/src/core/org/apache/hadoop/io/compress/bzip2/CBZip2InputStream.java

Modified: hadoop/common/branches/branch-1/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/CHANGES.txt?rev=1595525&r1=1595524&r2=1595525&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/CHANGES.txt (original)
+++ hadoop/common/branches/branch-1/CHANGES.txt Sat May 17 18:34:27 2014
@@ -58,6 +58,9 @@ Release 1.3.0 - unreleased
     MAPREDUCE-5712. Backport Fair Scheduler pool placement by secondary group
     (Ted Malaska via Sandy Ryza)
 
+    HADOOP-10614. CBZip2InputStream is not threadsafe (Xiangrui Meng via Sandy
+    Ryza)
+
   BUG FIXES
 
     HADOOP-9863. Backport HADOOP-8686 to support BigEndian on ppc64. 

Modified: hadoop/common/branches/branch-1/src/core/org/apache/hadoop/io/compress/bzip2/CBZip2InputStream.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/core/org/apache/hadoop/io/compress/bzip2/CBZip2InputStream.java?rev=1595525&r1=1595524&r2=1595525&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/src/core/org/apache/hadoop/io/compress/bzip2/CBZip2InputStream.java
(original)
+++ hadoop/common/branches/branch-1/src/core/org/apache/hadoop/io/compress/bzip2/CBZip2InputStream.java
Sat May 17 18:34:27 2014
@@ -126,7 +126,7 @@ public class CBZip2InputStream extends I
   private int computedBlockCRC, computedCombinedCRC;
 
   private boolean skipResult = false;// used by skipToNextMarker
-  private static boolean skipDecompression = false;
+  private boolean skipDecompression = false;
 
   // Variables used by setup* methods exclusively
 
@@ -278,12 +278,18 @@ public class CBZip2InputStream extends I
   */
   public CBZip2InputStream(final InputStream in, READ_MODE readMode)
       throws IOException {
+    this(in, readMode, false);
+  }
+
+  private CBZip2InputStream(final InputStream in, READ_MODE readMode, boolean skipDecompression)
+      throws IOException {
 
     super();
     int blockSize = 0X39;// i.e 9
     this.blockSize100k = blockSize - '0';
     this.in = new BufferedInputStream(in, 1024 * 9);// >1 MB buffer
     this.readMode = readMode;
+    this.skipDecompression = skipDecompression;
     if (readMode == READ_MODE.CONTINUOUS) {
       currentState = STATE.START_BLOCK_STATE;
       lazyInitialization = (in.available() == 0)?true:false;
@@ -313,11 +319,7 @@ public class CBZip2InputStream extends I
    *
    */
   public static long numberOfBytesTillNextMarker(final InputStream in) throws IOException{
-    CBZip2InputStream.skipDecompression = true;
-    CBZip2InputStream anObject = null;
-
-    anObject = new CBZip2InputStream(in, READ_MODE.BYBLOCK);
-
+    CBZip2InputStream anObject = new CBZip2InputStream(in, READ_MODE.BYBLOCK, true);
     return anObject.getProcessedByteCount();
   }
 
@@ -392,7 +394,7 @@ public class CBZip2InputStream extends I
 
     if(skipDecompression){
       changeStateToProcessABlock();
-      CBZip2InputStream.skipDecompression = false;
+      skipDecompression = false;
     }
 
     final int hi = offs + len;



Mime
View raw message