Repository navigation
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
bladehan1
force-pushed
the
fix/http-chunked-body-size-limit
branch
from
October 28, 2026 13:59
c76d903 to
f3c6b43
Compare
…tronprotocol#7072) * chore(deps): add missing POM checksums to verification metadata jsonrpc4j 1.7, jackson-databind 2.16.1 and jackson-annotations 2.16.1 have Gradle Module Metadata checksums but no POM checksums. When their metadata is read from a Maven-style repository without .module files, such as a local Maven repository picked up by mavenLocal(), Gradle uses the POM as metadata and strict dependency verification fails. Add the three POM SHA-256 checksums, generated by Gradle and checked against Maven Central. * chore(deps): upgrade Jackson from 2.18.10 to 2.18.12 Bump jackson-databind to 2.18.12; jackson-core and jackson-annotations follow through its dependencies and the Jackson BOM. Update the verification metadata: add jar, .module and .pom checksums for the 2.18.12 modules and the BOM and base POMs, and remove the 2.18.10 entries, which are no longer resolved by any configuration.
add one-byte read regressions for exact-limit acceptance and oversized request rejection, plus concurrent counter isolation and keep-alive reset coverage. rename the request-only handler and document why its parent handle method is bypassed.
extend HandlerWrapper directly and preserve request-limit checks bound test client connection and read waits to 15 seconds
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.
What does this PR do?
Fix premature rejection of valid unknown-length request bodies in the shared Jetty HTTP service. With a 4 MiB limit, the same 2–3 MiB body can pass with Content-Length but fail when sent chunked.
Add
AccurateSizeLimitHandlerand install it inHttpService. Keep the known Content-Length precheck; for unknown-length bodies, check Jetty'sHttpInput.getContentReceived()rather than accumulating intercepted buffer sizes. Configured limits and the existing public error policy are preserved.Why are these changes required?
Root cause:
SizeLimitHandler.LimitInterceptorIn Jetty
9.4.58.v20250814,LimitInterceptor.readFrom()performs:The
HttpInput.Interceptorcontract allows the sameContentto pass through an interceptor repeatedly.remaining()is a snapshot of the unread buffer, not newly received bytes. Accumulating it on every invocation counts bytes repeatedly, so the rejection point depends on buffering, chunk boundaries and application read patterns. This affects the unknown-length path; the known Content-Length precheck does not use this counter.Alternatives considered and selected design
Util.checkBodySize()ServletInputStream/ReaderThe replacement preserves existing input interceptors with
addInterceptor()and returns each Content unchanged. It delegates directly togetHandler().handle(...): callingsuper.handle(...)would reinstall the faultyLimitInterceptor. Downstream context, filters and servlets remain in the handler chain.This PR has been tested by:
Completed component test matrix
Local tests ran on macOS x86_64 / JDK 8 with Jetty 9.4.58. The independent probes recorded the same handler source hash as the current PR; their results remain separate from current-head CI and complete-node validation.
SizeLimitHandlerTest: 23/23 passed, including existing regressions.GetBlockByNumServletwith a mocked Wallet.JsonrpcServiceTest.testJsonRpcSizeLimitIntegrationpassed through JsonRpcServlet/jsonrpc4j.Local
clean build -x test, module Checkstyle and the full framework suite passed. A PR-base full-project test run encountered a plugins timeout; its isolated retry passed, which is recorded separately from a clean full-project run.Follow up
No additional implementation is proposed as part of this request-byte-counting fix. Response-size enforcement would be a separate feature: if it is introduced, the interception design and its tests must be extended together. The request-only boundary is explained below.
Extra details
Why the broader test suites are not acceptance gates for this fix
HttpServicealready usesresponseLimit = -1; this PR does not enable output enforcement. There is no active response-limit behavior to validate in this change. Positive response limits require a separate implementation and its output-specific tests, not an unfinished task in this fix.ReadListenerconsumptionsetReadListener/startAsyncregistration was found in the production sources checked. Current regression tests exercise the synchronous Reader/InputStream consumers used here; an asynchronous consumer must bring its own integration tests when introduced.HttpService.initContextHandler()installation path; no subclass override of that method was found. Existing per-service limit selection is unchanged. Shared-handler tests, two-service limit isolation and real HTTP/JSON-RPC integration cover the changed mechanism. Repeating identical byte-count tests on every port is not required to validate that shared implementation; this does not claim every service deployment was exercised.Component impact matrix
AccurateSizeLimitHandler/HttpInputsize > limitboundary remain. Direct component and socket coverage listed above.HttpServiceUtil.checkBodySize()remains a separate post-read check. Complete configuration-loading validation is not claimed.responseLimitis fixed to -1. See the explicit design boundary below.Request-only scope and future
responseLimitsupportAccurateSizeLimitHandlercallssuper(requestLimit, -1)and bypassesSizeLimitHandler.handle(). As a result, it does not install the parent's response-limiting output interceptor. This matches the existingHttpServiceuse, which already disables response limiting, but the subclass is not a general replacement supporting both limits.Supporting a positive
responseLimitlater requires refactoring how request and response interception are installed, for example into an explicitHandlerWrapperwith independently defined input/output enforcement. Merely adding a response-limit argument would leave the output check absent; callingsuper.handle()to restore it would reintroduce the buggy input interceptor. The refactor must preserve existing output interceptors and define counting/error semantics for buffered, streaming and already-committed responses before adding the corresponding test matrix. A separate application JSON-RPC response-size limit is not equivalent to this Jetty output limit.For valid CL requests without a parser conflict,
C > limitrejects before servlet dispatch, but does not guarantee an immediate response on the wire. WhenC <= limit, the current body is framed by C; additional connection bytes are not part of that body and must not be counted toward its limit.