GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [1.9.x] Bound the error response body read by RFC9457Reporter by slachiewicz · Pull Request #2122 · apache/maven-resolver

Conversation

@slachiewicz

@slachiewicz slachiewicz commented Sep 4, 2026

Copy link
Copy Markdown
Member

Ports the bounded error-body read from master (#2081) to the 1.9.x line. On this line RFC9457Reporter is a concrete class inside maven-resolver-transport-http rather than the SPI abstraction master has, so this is a port rather than a cherry-pick.

getBody previously handed the whole entity to EntityUtils.toString, so the size of an error response body was decided by the server. It now reads at most 64 KiB (MAX_BODY_BYTES) and leaves the rest unread. A body that does not parse as problem details, including one truncated at the limit, no longer surfaces as a JsonSyntaxException from RFC9457Parser: generateException returns and HttpTransporter.handleStatus reports the plain HttpResponseException for the status, the same fallback master uses.

The test server gained two rfc9457/ paths, a non-JSON body and a payload larger than the limit, and both are expected to arrive as a plain 403 rather than as problem details.

Verified: mvn -pl maven-resolver-transport-http -am verify -> BUILD SUCCESS, 91 tests in the module, 0 failures; spotless:apply produced no further changes.

This change was created with AI assistance.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@slachiewicz
Bound the error response body read by RFC9457Reporter on 1.9.x
17eb5c9
Read at most 64 KiB of an error response body and fall back to the plain
HTTP status when the problem details cannot be parsed, instead of
buffering the whole entity and letting a malformed body surface as a
JSON parse error.
@slachiewicz slachiewicz added bug Something isn't working resolver1 maintenance labels Sep 4, 2026
@slachiewicz
slachiewicz marked this pull request as ready for review September 4, 2026 21:41
gnodet
gnodet approved these changes Sep 4, 2026
View reviewed changes

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

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.

Clean, correct backport of the bounded error-body read from master (#2081) to the 1.9.x concrete RFC9457Reporter. The readBody implementation faithfully reproduces master, the fallback from malformed/truncated bodies to the plain HTTP status is properly wired, and test coverage is adequate.

Positive notes:

  • readBody() correctly caps at MAX_BODY_BYTES (64 KiB), handles EOF, and uses the same 8 KiB chunk size as master.
  • The ByteArrayOutputStream approach avoids pre-allocating the full 64 KiB for smaller bodies.
  • Null check on RFC9457Parser.parse() return value guards against Gson.fromJson returning Java null for JSON literal null.
  • Truncated stream is closed via try-with-resources; EntityUtils.consumeQuietly() in the caller's finally block handles the already-closed stream gracefully.
  • Test framework correctly uses JUnit 4, matching 1.9.x convention.

Low-severity observation (non-blocking):

  • Master's RFC9457ReporterTest has additional unit tests for generateException() directly. The 1.9.x port covers these scenarios through integration tests in HttpTransporterTest, which is acceptable but leaves unit-level behavior less directly tested.

📋 PR Metadata

Aspect Current Suggested
Milestone (none) 1.9.28

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of Guillaume Nodet

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@slachiewicz slachiewicz closed this Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gnodet gnodet gnodet approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

bug Something isn't working maintenance resolver1

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@slachiewicz @gnodet
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.