Skip to content

AVRO-4241: [Java] BinaryDecoder should verify available bytes before reading#3725

Open
iemejia wants to merge 1 commit intoapache:mainfrom
iemejia:AVRO-4241-binarydecoder-verify-available-bytes-before-read
Open

AVRO-4241: [Java] BinaryDecoder should verify available bytes before reading#3725
iemejia wants to merge 1 commit intoapache:mainfrom
iemejia:AVRO-4241-binarydecoder-verify-available-bytes-before-read

Conversation

@iemejia
Copy link
Copy Markdown
Member

@iemejia iemejia commented Apr 6, 2026

Add ensureAvailableBytes() pre-check in readString, readBytes, readArrayStart, arrayNext, readMapStart, and mapNext to verify the source has sufficient data before proceeding.

Byte-array-backed sources return an exact remaining count. Stream-backed sources return buffered bytes plus InputStream.available(), which is reliable for the finite streams used by DataFileReader and DataFileStream.

Includes regression tests and updated array/map limit tests.

R: @RyanSkraba @martin-g

What is the purpose of the change

(For example: This pull request improves file read performance by buffering data, fixing AVRO-XXXX.)

Verifying this change

(Please pick one of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Extended interop tests to verify consistent valid schema names between SDKs
  • Added test that validates that Java throws an AvroRuntimeException on invalid binary data
  • Manually verified the change by building the website and checking the new redirect

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

@github-actions github-actions bot added the Java Pull Requests for Java binding label Apr 6, 2026
@iemejia iemejia force-pushed the AVRO-4241-binarydecoder-verify-available-bytes-before-read branch 3 times, most recently from ef9c52a to ce192d2 Compare April 7, 2026 13:44
…reading

Add ensureAvailableBytes() pre-check in readString, readBytes,
readArrayStart, arrayNext, readMapStart, and mapNext to verify the
source has sufficient data before proceeding.

Byte-array-backed sources return an exact remaining count.
Stream-backed sources return buffered bytes plus InputStream.available(),
which is reliable for the finite streams used by DataFileReader and
DataFileStream.

Includes regression tests and updated array/map limit tests.
@iemejia iemejia force-pushed the AVRO-4241-binarydecoder-verify-available-bytes-before-read branch from ce192d2 to 8471fc2 Compare April 7, 2026 15:35
@iemejia iemejia requested review from RyanSkraba and martin-g April 8, 2026 07:25
@iemejia iemejia changed the title AVRO-4241: [Java] BinaryDecoder should verify available bytes before … AVRO-4241: [Java] BinaryDecoder should verify available bytes before reading Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Java Pull Requests for Java binding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants