AVRO-4247: [Java] Enforce decompression size limits (branch-1.11 backport)#3777
Merged
Merged
Conversation
Cherry-pick of d28279d from master with Java 8 compatibility fixes: - Replace Objects.checkFromIndexSize() (Java 9+) with manual bounds check - Replace ByteArrayOutputStream.writeBytes() override (Java 11+) with standalone method delegating to write(b, 0, b.length)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
org.apache.avro.limits.decompress.maxLengthNonCopyingByteArrayOutputStream(used by stream-based codecs) and directly inSnappyCodec(which usesByteBuffer)Java 8 compatibility fixes
Since branch-1.11 targets Java 8 while master targets Java 11, the following changes were made on top of the cherry-pick:
Objects.checkFromIndexSize()(Java 9+) with equivalent manual bounds checkingByteArrayOutputStream.writeBytes()override (Java 11+) with a standalone method delegating towrite(b, 0, b.length)java.util.ObjectsimportTesting
All 198 tests pass (66 tests x 3 execution modes: default, custom-coders, fast-reader), including:
NonCopyingByteArrayOutputStreamTest- 5 new tests for limit enforcementTestAllCodecs- 12 tests covering all codec roundtripsTestDataFile*- full data file read/write tests across all codecsR: @RyanSkraba
CC: @steveloughran (for awareness of the cherry-pick)