HADOOP-10614. CBZip2InputStream is not threadsafe (Xiangrui Meng via Sandy Ryza)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1595523 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
644743599c
commit
fa76a87dbe
|
@ -55,6 +55,9 @@ Release 2.5.0 - UNRELEASED
|
||||||
|
|
||||||
HADOOP-10609. .gitignore should ignore .orig and .rej files. (kasha)
|
HADOOP-10609. .gitignore should ignore .orig and .rej files. (kasha)
|
||||||
|
|
||||||
|
HADOOP-10614. CBZip2InputStream is not threadsafe (Xiangrui Meng via
|
||||||
|
Sandy Ryza)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
|
|
@ -129,7 +129,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
|
||||||
private int computedBlockCRC, computedCombinedCRC;
|
private int computedBlockCRC, computedCombinedCRC;
|
||||||
|
|
||||||
private boolean skipResult = false;// used by skipToNextMarker
|
private boolean skipResult = false;// used by skipToNextMarker
|
||||||
private static boolean skipDecompression = false;
|
private boolean skipDecompression = false;
|
||||||
|
|
||||||
// Variables used by setup* methods exclusively
|
// Variables used by setup* methods exclusively
|
||||||
|
|
||||||
|
@ -281,12 +281,18 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
|
||||||
*/
|
*/
|
||||||
public CBZip2InputStream(final InputStream in, READ_MODE readMode)
|
public CBZip2InputStream(final InputStream in, READ_MODE readMode)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
this(in, readMode, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CBZip2InputStream(final InputStream in, READ_MODE readMode, boolean skipDecompression)
|
||||||
|
throws IOException {
|
||||||
|
|
||||||
super();
|
super();
|
||||||
int blockSize = 0X39;// i.e 9
|
int blockSize = 0X39;// i.e 9
|
||||||
this.blockSize100k = blockSize - '0';
|
this.blockSize100k = blockSize - '0';
|
||||||
this.in = new BufferedInputStream(in, 1024 * 9);// >1 MB buffer
|
this.in = new BufferedInputStream(in, 1024 * 9);// >1 MB buffer
|
||||||
this.readMode = readMode;
|
this.readMode = readMode;
|
||||||
|
this.skipDecompression = skipDecompression;
|
||||||
if (readMode == READ_MODE.CONTINUOUS) {
|
if (readMode == READ_MODE.CONTINUOUS) {
|
||||||
currentState = STATE.START_BLOCK_STATE;
|
currentState = STATE.START_BLOCK_STATE;
|
||||||
lazyInitialization = (in.available() == 0)?true:false;
|
lazyInitialization = (in.available() == 0)?true:false;
|
||||||
|
@ -316,11 +322,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static long numberOfBytesTillNextMarker(final InputStream in) throws IOException{
|
public static long numberOfBytesTillNextMarker(final InputStream in) throws IOException{
|
||||||
CBZip2InputStream.skipDecompression = true;
|
CBZip2InputStream anObject = new CBZip2InputStream(in, READ_MODE.BYBLOCK, true);
|
||||||
CBZip2InputStream anObject = null;
|
|
||||||
|
|
||||||
anObject = new CBZip2InputStream(in, READ_MODE.BYBLOCK);
|
|
||||||
|
|
||||||
return anObject.getProcessedByteCount();
|
return anObject.getProcessedByteCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,7 +399,7 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants {
|
||||||
|
|
||||||
if(skipDecompression){
|
if(skipDecompression){
|
||||||
changeStateToProcessABlock();
|
changeStateToProcessABlock();
|
||||||
CBZip2InputStream.skipDecompression = false;
|
skipDecompression = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int hi = offs + len;
|
final int hi = offs + len;
|
||||||
|
|
Loading…
Reference in New Issue