-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HADOOP-19908. ZStandardDecompressor should reset compressedDirectBuf correctly #8526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -92,7 +92,7 @@ private void setInputFromSavedData() { | |
| bytesInCompressedBuffer = directBufferSize; | ||
| } | ||
|
|
||
| compressedDirectBuf.rewind(); | ||
| compressedDirectBuf.clear(); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. another defensive change, ensures |
||
| compressedDirectBuf.put( | ||
| userBuf, userBufOff, bytesInCompressedBuffer); | ||
|
|
||
|
|
@@ -188,6 +188,9 @@ public int decompress(byte[] b, int off, int len) | |
| } | ||
|
|
||
| // Restore limit so setInputFromSavedData() can rewind+put on next call. | ||
| // There is possible that `decompressDirectByteBufferStream` throws exception | ||
| // on decompressing corrupt data, code won't reach here, the caller must | ||
| // call `reset` to clear the state before resuing this decompressor. | ||
| compressedDirectBuf.limit(directBufferSize); | ||
| } else { | ||
| n = 0; | ||
|
|
@@ -225,6 +228,8 @@ public void reset() { | |
| finished = false; | ||
| compressedDirectBufOff = 0; | ||
| bytesInCompressedBuffer = 0; | ||
| compressedDirectBuf.limit(directBufferSize); | ||
| compressedDirectBuf.position(0); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is the real fix, other places are defensive changes. |
||
| uncompressedDirectBuf.limit(directBufferSize); | ||
| uncompressedDirectBuf.position(directBufferSize); | ||
| userBufOff = 0; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a defensive change, I don't think
rewind(means only resetpositionbut notlimit) causes any problems, but we'd better callclearto gain correct semantics.