Skip to content

Commit 58896f0

Browse files
HADOOP-19339. OutofBounds Exception due to assumption about buffer size in BlockCompressorStream. Contributed by ConfX.
Co-authored-by: saadsheralam <[email protected]> Signed-off-by: He Xiaoqiao <[email protected]>
1 parent de8b506 commit 58896f0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/BlockCompressorStream.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ public class BlockCompressorStream extends CompressorStream {
5454
public BlockCompressorStream(OutputStream out, Compressor compressor,
5555
int bufferSize, int compressionOverhead) {
5656
super(out, compressor, bufferSize);
57-
MAX_INPUT_SIZE = bufferSize - compressionOverhead;
57+
if (bufferSize - compressionOverhead >= 0) {
58+
MAX_INPUT_SIZE = bufferSize - compressionOverhead;
59+
} else {
60+
throw new IllegalArgumentException("buffer size is less than compression overhead");
61+
}
5862
}
5963

6064
/**

0 commit comments

Comments
 (0)