Repository navigation
Conversation
Route array and CharBuffer reads through the existing bounded read paths. Related to SLING-13268. Assisted-By: OpenAI Codex
Cover array reads, heap and direct CharBuffer reads, count updates, read-only buffers, and IOUtils.copy respecting the configured bound. Assisted-By: OpenAI Codex
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.
BoundedReader inherits read(char[]) and read(CharBuffer) from ProxyReader. Both inherited methods delegate directly to the wrapped reader, bypassing BoundedReader's limit and character count. For example, IOUtils.copy(new BoundedReader(new StringReader("01234567890"), 3), writer) currently copies all 11 characters instead of 3.
Override both overloads so that they use the existing bounded read paths. Preserve the destination CharBuffer position and reject a read-only buffer before consuming input. Regression tests cover array reads, heap and direct CharBuffers, mixed read calls, EOF and empty destinations, read-only buffers, and IOUtils.copy.
Related to SLING-13268, where the downstream workaround replaced BoundedReader after it stopped enforcing the bound with IOUtils.copy. This PR addresses the upstream reader behavior.
Validation on Windows with Java 21 and Maven 3.9.6:
mvn -B -ntp -Dtest=BoundedReaderTest testran 25 tests with 5 failures, demonstrating the regression.mvn -B -ntp -DskipTests -DskipITspassed the default build and non-test checks, including RAT, binary compatibility, Checkstyle, SpotBugs, PMD, and Javadoc.mvn -B -ntprun completed with 7,315 tests, 3 failures, 60 errors, and 51 skipped. The failures/errors were caused by missing Windows symbolic-link privileges and one HTTPS handshake failure in URIOriginTest. BoundedReaderTest passed in this run. The full default build is therefore left unchecked below.AI disclosure: OpenAI Codex generated the implementation, regression tests, commit descriptions, and this PR description, and performed repository inspection and validation. Both commits include
Assisted-By: OpenAI Codex.mvn(environment limitations described above).