AVRO-4268: BytesWritableConverter should respect logical length - #3878
Merged
RyanSkraba merged 1 commit intoJul 19, 2026
Merged
Conversation
BytesWritable.getBytes() returns the backing array, which can be larger than the logical length reported by BytesWritable.getLength(). Wrap input.getBytes() with the actual length so the Avro bytes value reflects the caller's data, not unused backing-array capacity. Adds convertBytesWritableRespectsLogicalLength to cover the regression. Signed-off-by: Harsh Srivastava <harsh10822@gmail.com>
RyanSkraba
pushed a commit
that referenced
this pull request
Jul 19, 2026
BytesWritable.getBytes() returns the backing array, which can be larger than the logical length reported by BytesWritable.getLength(). Wrap input.getBytes() with the actual length so the Avro bytes value reflects the caller's data, not unused backing-array capacity. Adds convertBytesWritableRespectsLogicalLength to cover the regression. Signed-off-by: Harsh Srivastava <harsh10822@gmail.com>
Contributor
|
Cherry-picked to branch-1.12. We don't require a CLA, but if you'd like credit in our bug tracker, don't hesitate to create an account and we'll assign it to you! https://issues.apache.org/jira/browse/AVRO-4268 Thanks again for the fix. |
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.
Closes AVRO-4268
What was wrong
BytesWritablecan use a backing array that is larger than the value itcurrently contains. The converter used the entire backing array, so unused
bytes could be included in the Avro value.
What changed
The converter now uses
BytesWritable.getLength()and includes only thebytes that belong to the current value.
A regression test covers a five-byte backing array whose logical value is only
three bytes.
Testing
lang/java/mapredsuite: 110 passed, 0 failed, 0 errors, 0 skippedgit diff --checkpassedThe commit is signed off using
harsh10822@gmail.com. Please let me know ifany ASF CLA action is required.