Skip to content

feat(http): add SizeLimitHandler to enforce request body size limit#1

Open
bladehan1 wants to merge 19 commits intodevelopfrom
feat/request_size
Open

feat(http): add SizeLimitHandler to enforce request body size limit#1
bladehan1 wants to merge 19 commits intodevelopfrom
feat/request_size

Conversation

@bladehan1
Copy link
Copy Markdown
Owner

@bladehan1 bladehan1 commented Mar 19, 2026

What does this PR do?

Add Jetty SizeLimitHandler at the server handler level to enforce request body size limits for all HTTP and JSON-RPC endpoints. Oversized requests are rejected with HTTP 413 before the body is fully buffered into memory.

  • Introduce node.http.maxMessageSize and node.jsonrpc.maxMessageSize as independent, configurable size limits
  • Default: GrpcUtil.DEFAULT_MAX_MESSAGE_SIZE (4 MB), consistent with gRPC defaults
  • Wire SizeLimitHandler into HttpService.initContextHandler() as the outermost handler
  • Each HttpService subclass (4 HTTP + 3 JSON-RPC) sets maxRequestSize from the corresponding config getter
  • Deprecate Util.checkBodySize() — retained as fallback for backward compatibility

Why are these changes required?

Previously, HTTP request body size was only validated at the application layer (Util.checkBodySize()), which reads the entire body into memory before checking. The JSON-RPC interface had no size validation at all. This allows an attacker to send arbitrarily large payloads, causing OOM and denial of service.

Moving the limit to the Jetty handler chain provides:

  1. Early rejection — oversized requests are stopped before reaching servlet code
  2. Streaming enforcement — limits are enforced during read, not after full buffering
  3. Unified coverage — all HTTP and JSON-RPC endpoints are protected by a single mechanism
  4. Independent tuning — operators can configure HTTP and JSON-RPC limits separately

This PR has been tested by:

  • Unit Tests (SizeLimitHandlerTest: boundary, independent limits, UTF-8 byte counting)
  • Unit Tests (ArgsTest: default value alignment)

Follow up

  • Remove Util.checkBodySize() callers in a follow-up PR once this is stable
  • Compression bomb (gzip decompression) protection is a separate concern, tracked independently

Extra details

Files changed: 14 (+253 / -2)

Component Changes
HttpService Add maxRequestSize field, wire SizeLimitHandler in initContextHandler()
Args / ConfigKey / CommonParameter Parse node.http.maxMessageSize and node.jsonrpc.maxMessageSize
7 service subclasses Set maxRequestSize from protocol-specific getter in constructor
Util.checkBodySize() Mark @Deprecated
SizeLimitHandlerTest New: 8 tests covering HTTP/JSON-RPC limits, boundary, UTF-8, independence
ArgsTest Align assertions with 4 MB defaults

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 19, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds configurable per-service request-size limits: HttpService now wraps its ServletContextHandler with Jetty SizeLimitHandler and uses new Args/config keys and CommonParameter fields; multiple HTTP/JSON‑RPC services set maxRequestSize. Deprecates Util.checkBodySize and adds integration tests validating 200 vs 413 and UTF‑8 byte-length enforcement.

Changes

Cohort / File(s) Summary
HttpService + Size limiting
framework/src/main/java/org/tron/common/application/HttpService.java
Added protected int maxRequestSize and wrapped the ServletContextHandler with Jetty SizeLimitHandler, using it as the server handler to enforce request/stream size limits.
Config & Params
framework/src/main/java/org/tron/core/config/args/ConfigKey.java, framework/src/main/java/org/tron/core/config/args/Args.java, common/src/main/java/org/tron/common/parameter/CommonParameter.java
Added config keys node.http.maxMessageSize and node.jsonrpc.maxMessageSize; Args reads/validates them and CommonParameter gains httpMaxMessageSize and jsonRpcMaxMessageSize.
Service constructors updated
framework/src/main/java/org/tron/core/services/http/FullNodeHttpApiService.java, framework/src/main/java/org/tron/core/services/http/solidity/SolidityNodeHttpApiService.java, framework/src/main/java/org/tron/core/services/interfaceJsonRpcOnPBFT/JsonRpcServiceOnPBFT.java, framework/src/main/java/org/tron/core/services/interfaceJsonRpcOnSolidity/JsonRpcServiceOnSolidity.java, framework/src/main/java/org/tron/core/services/interfaceOnPBFT/http/PBFT/HttpApiOnPBFTService.java, framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/solidity/HttpApiOnSolidityService.java, framework/src/main/java/org/tron/core/services/jsonrpc/FullNodeJsonRpcHttpService.java
Each service constructor now assigns maxRequestSize from Args (HTTP or JSON‑RPC specific) so SizeLimitHandler enforces per-service limits.
Deprecation
framework/src/main/java/org/tron/core/services/http/Util.java
Marked checkBodySize(String) as @Deprecated without changing signature or behavior.
Tests
framework/src/test/java/org/tron/common/jetty/SizeLimitHandlerTest.java, framework/src/test/java/org/tron/core/config/args/ArgsTest.java
Added integration tests that start HttpService instances to verify POSTs within/over limits return 200/413, check independent HTTP vs JSON‑RPC limits and UTF‑8 byte‑length behavior; updated ArgsTest assertions.

Sequence Diagram

sequenceDiagram
    participant Client
    participant SizeLimitHandler
    participant ServletContextHandler
    participant EchoServlet

    Client->>SizeLimitHandler: POST /endpoint (body bytes)
    alt body ≤ MaxMessageSize
        SizeLimitHandler->>ServletContextHandler: forward request
        ServletContextHandler->>EchoServlet: dispatch request
        EchoServlet-->>Client: 200 OK (echo)
    else body > MaxMessageSize
        SizeLimitHandler-->>Client: 413 Payload Too Large
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 I counted bytes with careful feet,
Small hops pass, big burdens meet the street,
A gate of limits keeps the stream tight,
Tests hum “two-zero-zero” or “four-one-three” at night,
I nibble code and keep the routes light.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the main change: adding a SizeLimitHandler to enforce request body size limits, which is the core feature across the changeset.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/request_size

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files


Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
framework/src/test/java/org/tron/common/jetty/SizeLimitHandlerTest.java (2)

40-43: Add a multibyte UTF-8 test to match the stated behavior.

Line 42 claims byte-based UTF-8 enforcement, but current tests only use single-byte ASCII payloads. Add one case with multibyte characters to prove the contract.

Also applies to: 119-122

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@framework/src/test/java/org/tron/common/jetty/SizeLimitHandlerTest.java`
around lines 40 - 43, Add a new test in SizeLimitHandlerTest (e.g.
testUtf8MultibyteByteLimit) that constructs request bodies containing multibyte
UTF-8 characters (for example "€" or an emoji) whose Java char count differs
from UTF-8 byte count, then send requests against the existing size-limit
handler asserting that a payload whose UTF-8 byte length is within the
configured limit returns 200 and one whose UTF-8 byte length exceeds the limit
returns 413; update or add both the earlier test block around lines ~40–43 and
the later assertions around ~119–122 to include these multibyte cases so the
test suite verifies byte-based (not char-based) enforcement.

127-133: Close HTTP responses explicitly using try-with-resources.

The current code consumes the entity but does not close the CloseableHttpResponse. Per Apache HttpClient 4.x documentation, closing the response object is mandatory to ensure proper resource deallocation. Use try-with-resources with CloseableHttpResponse:

Proposed refactor
+import org.apache.http.client.methods.CloseableHttpResponse;
...
   private int post(HttpEntity entity) throws Exception {
     HttpPost req = new HttpPost(serverUri);
     req.setEntity(entity);
-    HttpResponse resp = client.execute(req);
-    EntityUtils.consume(resp.getEntity());
-    return resp.getStatusLine().getStatusCode();
+    try (CloseableHttpResponse resp = client.execute(req)) {
+      EntityUtils.consume(resp.getEntity());
+      return resp.getStatusLine().getStatusCode();
+    }
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@framework/src/test/java/org/tron/common/jetty/SizeLimitHandlerTest.java`
around lines 127 - 133, The post method does not close the HTTP response; update
the post(HttpEntity entity) method to use a try-with-resources block that
obtains a CloseableHttpResponse from client.execute(req) (replace HttpResponse
with CloseableHttpResponse) and ensure EntityUtils.consume(resp.getEntity()) is
called inside the try so the response is closed automatically; keep returning
resp.getStatusLine().getStatusCode() but read it from the closed-response
variable inside the try block.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@framework/src/main/java/org/tron/common/application/HttpService.java`:
- Around line 67-70: The maxMessageSize returned by
Args.getInstance().getMaxMessageSize() is used directly to construct a
SizeLimitHandler in HttpService, but Jetty only supports values >= -1 and a
value of 0 is nonsensical; add a startup guard in HttpService before new
SizeLimitHandler(...) that validates the value (require maxMessageSize == -1 ||
maxMessageSize >= 1), and if invalid throw an IllegalArgumentException (or log
error and exit) with a clear message referencing maxMessageSize so the process
fails fast and apiServer.setHandler(...) is never called with an unsupported
size.

In `@framework/src/test/java/org/tron/common/jetty/SizeLimitHandlerTest.java`:
- Line 92: The test calls httpService.start() (in SizeLimitHandlerTest) but
doesn't wait for the returned CompletableFuture<Boolean> to complete; update the
setup to synchronously wait for startup (e.g., call start().get(...) or
start().join() with a reasonable timeout and assert the result is true) and
propagate or fail the test on interruption/exception so the test only proceeds
after the service has fully started.

---

Nitpick comments:
In `@framework/src/test/java/org/tron/common/jetty/SizeLimitHandlerTest.java`:
- Around line 40-43: Add a new test in SizeLimitHandlerTest (e.g.
testUtf8MultibyteByteLimit) that constructs request bodies containing multibyte
UTF-8 characters (for example "€" or an emoji) whose Java char count differs
from UTF-8 byte count, then send requests against the existing size-limit
handler asserting that a payload whose UTF-8 byte length is within the
configured limit returns 200 and one whose UTF-8 byte length exceeds the limit
returns 413; update or add both the earlier test block around lines ~40–43 and
the later assertions around ~119–122 to include these multibyte cases so the
test suite verifies byte-based (not char-based) enforcement.
- Around line 127-133: The post method does not close the HTTP response; update
the post(HttpEntity entity) method to use a try-with-resources block that
obtains a CloseableHttpResponse from client.execute(req) (replace HttpResponse
with CloseableHttpResponse) and ensure EntityUtils.consume(resp.getEntity()) is
called inside the try so the response is closed automatically; keep returning
resp.getStatusLine().getStatusCode() but read it from the closed-response
variable inside the try block.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3995e317-a92d-45c4-ac9b-e5d7296b806c

📥 Commits

Reviewing files that changed from the base of the PR and between 7e5bbbd and 50496d5.

📒 Files selected for processing (3)
  • framework/src/main/java/org/tron/common/application/HttpService.java
  • framework/src/main/java/org/tron/core/services/http/Util.java
  • framework/src/test/java/org/tron/common/jetty/SizeLimitHandlerTest.java

Comment thread framework/src/main/java/org/tron/common/application/HttpService.java Outdated
Comment thread framework/src/test/java/org/tron/common/jetty/SizeLimitHandlerTest.java Outdated
@bladehan1 bladehan1 changed the title feat(http): add Jetty SizeLimitHandler to enforce request body size l… feat(http): add Jetty SizeLimitHandler to enforce request body size limit Mar 19, 2026
@bladehan1 bladehan1 changed the title feat(http): add Jetty SizeLimitHandler to enforce request body size limit feat(http): add SizeLimitHandler to enforce request body size limit Mar 19, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
framework/src/test/java/org/tron/common/jetty/SizeLimitHandlerTest.java (2)

102-103: Redundant Args configuration.

These lines set max message sizes on Args, but TestHttpService and TestJsonRpcService receive their limits directly via constructor parameters (lines 106, 111) and don't read from Args. This code has no effect on test behavior and could be removed for clarity.

Suggested removal
    Args.setParam(new String[]{"-d", temporaryFolder.newFolder().toString()},
        TestConstants.TEST_CONF);
-    Args.getInstance().setHttpMaxMessageSize(HTTP_MAX_BODY_SIZE);
-    Args.getInstance().setJsonRpcMaxMessageSize(JSONRPC_MAX_BODY_SIZE);

    int httpPort = PublicMethod.chooseRandomPort();
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@framework/src/test/java/org/tron/common/jetty/SizeLimitHandlerTest.java`
around lines 102 - 103, Remove the redundant global Args configuration that sets
HTTP_MAX_BODY_SIZE and JSONRPC_MAX_BODY_SIZE via
Args.getInstance().setHttpMaxMessageSize(...) and setJsonRpcMaxMessageSize(...);
these calls have no effect because TestHttpService and TestJsonRpcService
receive their limits directly through constructor parameters (see
TestHttpService and TestJsonRpcService instantiations using HTTP_MAX_BODY_SIZE
and JSONRPC_MAX_BODY_SIZE), so delete those two set* calls to avoid confusion
and clarify the test setup.

31-42: Documentation claims default value testing, but no test verifies defaults.

Line 41 states the test covers "Default values are 4x GrpcUtil.DEFAULT_MAX_MESSAGE_SIZE", but all tests use explicit limits passed to the service constructors. Consider either adding a test that verifies the actual default configuration or removing this claim from the documentation.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@framework/src/test/java/org/tron/common/jetty/SizeLimitHandlerTest.java`
around lines 31 - 42, The Javadoc claims default limits are 4x
GrpcUtil.DEFAULT_MAX_MESSAGE_SIZE but no test verifies that; either add a unit
test in SizeLimitHandlerTest that constructs the service using the
no-argument/default constructor (or calls HttpService.initContextHandler()
without passing explicit limits), retrieves the configured SizeLimitHandler (or
exercises the endpoint with payloads sized at GrpcUtil.DEFAULT_MAX_MESSAGE_SIZE
* 4 and *4+1) and asserts the behavior matches the 4x default, or simply remove
the bullet "Default values are 4x GrpcUtil.DEFAULT_MAX_MESSAGE_SIZE" from the
class Javadoc if you don’t want to add a runtime verification; look for the test
class SizeLimitHandlerTest and the HttpService initContextHandler()/constructor
usages to implement the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@framework/src/test/java/org/tron/common/jetty/SizeLimitHandlerTest.java`:
- Around line 102-103: Remove the redundant global Args configuration that sets
HTTP_MAX_BODY_SIZE and JSONRPC_MAX_BODY_SIZE via
Args.getInstance().setHttpMaxMessageSize(...) and setJsonRpcMaxMessageSize(...);
these calls have no effect because TestHttpService and TestJsonRpcService
receive their limits directly through constructor parameters (see
TestHttpService and TestJsonRpcService instantiations using HTTP_MAX_BODY_SIZE
and JSONRPC_MAX_BODY_SIZE), so delete those two set* calls to avoid confusion
and clarify the test setup.
- Around line 31-42: The Javadoc claims default limits are 4x
GrpcUtil.DEFAULT_MAX_MESSAGE_SIZE but no test verifies that; either add a unit
test in SizeLimitHandlerTest that constructs the service using the
no-argument/default constructor (or calls HttpService.initContextHandler()
without passing explicit limits), retrieves the configured SizeLimitHandler (or
exercises the endpoint with payloads sized at GrpcUtil.DEFAULT_MAX_MESSAGE_SIZE
* 4 and *4+1) and asserts the behavior matches the 4x default, or simply remove
the bullet "Default values are 4x GrpcUtil.DEFAULT_MAX_MESSAGE_SIZE" from the
class Javadoc if you don’t want to add a runtime verification; look for the test
class SizeLimitHandlerTest and the HttpService initContextHandler()/constructor
usages to implement the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 16fd687d-e769-4afd-9430-005c0b361dbb

📥 Commits

Reviewing files that changed from the base of the PR and between b2ade66 and c41d30e.

📒 Files selected for processing (1)
  • framework/src/test/java/org/tron/common/jetty/SizeLimitHandlerTest.java

@bladehan1 bladehan1 force-pushed the feat/request_size branch from 24abc3a to 3048750 Compare April 9, 2026 10:43
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 issues found across 6 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="framework/src/main/java/org/tron/core/config/args/Args.java">

<violation number="1" location="framework/src/main/java/org/tron/core/config/args/Args.java:477">
P2: Reject zero for `node.rpc.maxMessageSize`; allowing 0 creates an unusable RPC payload limit.</violation>

<violation number="2" location="framework/src/main/java/org/tron/core/config/args/Args.java:487">
P2: `node.http.maxMessageSize` should remain strictly positive; allowing 0 makes HTTP endpoints reject normal request bodies.</violation>

<violation number="3" location="framework/src/main/java/org/tron/core/config/args/Args.java:494">
P2: `node.jsonrpc.maxMessageSize` should reject 0 to avoid a silently unusable JSON-RPC API limit.</violation>
</file>

<file name="framework/src/test/java/org/tron/common/jetty/SizeLimitHandlerTest.java">

<violation number="1" location="framework/src/test/java/org/tron/common/jetty/SizeLimitHandlerTest.java:75">
P2: `body.getBytes()` uses the platform default charset, making UTF-8 byte-length assertions environment-dependent.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread framework/src/main/java/org/tron/core/config/args/Args.java Outdated
Comment thread framework/src/main/java/org/tron/core/config/args/Args.java Outdated
Comment thread framework/src/main/java/org/tron/core/config/args/Args.java
@cubic-dev-ai
Copy link
Copy Markdown

cubic-dev-ai Bot commented Apr 20, 2026

You're iterating quickly on this pull request. To help protect your rate limits, cubic has paused automatic reviews on new pushes for now—when you're ready for another review, comment @cubic-dev-ai review.

…imit

Add SizeLimitHandler at the Jetty server level to reject oversized
request bodies before they are fully buffered into memory. This prevents
OOM attacks via arbitrarily large HTTP payloads that bypass the existing
application-level Util.checkBodySize() check (which reads the entire
body first) and the JSON-RPC interface (which had no size validation).
Introduce node.http.maxMessageSize and node.jsonrpc.maxMessageSize to
allow HTTP and JSON-RPC services to enforce separate request body size
limits via Jetty SizeLimitHandler, decoupled from gRPC config.

- Default: 4 * GrpcUtil.DEFAULT_MAX_MESSAGE_SIZE (16 MB)
- Validation: reject <= 0 with TronError(PARAMETER_INIT) at startup
- Each HttpService subclass sets its own maxRequestSize in constructor
- SizeLimitHandlerTest covers independent limits, boundary, UTF-8 bytes
checkBodySize() was enforcing maxMessageSize (gRPC limit) instead of
httpMaxMessageSize, causing the independent HTTP size setting to be
ineffective at the servlet layer.
…ndler

Add tests to cover scenarios raised in PR review:
- Chunked (no Content-Length) requests within/exceeding the limit
- Servlet broad catch(Exception) absorbing streaming BadMessageException
- SizeLimitHandler behavior when limit is 0 (rejects all non-empty bodies)
Replace EchoServlet with BroadCatchServlet to mirror real servlet chain.
Replace getInt() with getMemorySize().toBytes() for maxMessageSize,
httpMaxMessageSize and jsonRpcMaxMessageSize config parsing. This
enables human-readable size values (e.g. 4m, 128MB) while maintaining
backward compatibility with raw byte values.

- maxMessageSize (gRPC): keep int field, validate <= Integer.MAX_VALUE
  for gRPC API compatibility, add positive value validation
- httpMaxMessageSize / jsonRpcMaxMessageSize: widen to long, matching
  Jetty SizeLimitHandler's long parameter type
- Add config.conf documentation for all three size parameters
Change validation from <= 0 to < 0 for all three size limit configs.
Zero is a valid value meaning "reject all non-empty request bodies",
with consistent semantics in both gRPC (maxInboundMessageSize >= 0)
and Jetty SizeLimitHandler (limit >= 0 && size > limit).
Add tests proving the two enforcement layers measure identical byte
counts for normal JSON payloads (ASCII and UTF-8). For bodies with
\r\n line endings, checkBodySize measures fewer bytes than wire —
a safe direction that never causes false rejections.
Zero is a valid value for all three maxMessageSize parameters,
so the config documentation should say "non-negative" not "positive".
…iable name

Initialize HttpService.maxRequestSize to 4MB so future subclasses that
omit the assignment get a safe limit instead of 0 (reject all requests).
Rename defaultHttpMaxMessageSize to defaultMaxMessageSize since it serves
as the fallback for both HTTP and JSON-RPC limits.
Add comprehensive ArgsTest coverage for getMemorySize() parsing:
- Human-readable sizes across KB/MB/GB tiers (binary and SI units)
- Raw integer backward compatibility
- Zero-value acceptance
- Error paths: exceeds int max, negative value, invalid unit, non-numeric

Document zero-value behavior in config.conf for all three maxMessageSize
entries: "Setting to 0 rejects all non-empty request bodies".
…Handler tests

Add testJsonRpcSizeLimitIntegration() in JsonrpcServiceTest using the
Spring-injected FullNodeJsonRpcHttpService (real JsonRpcServlet + jsonrpc4j)
to verify SizeLimitHandler does not introduce regressions. Covers: normal
request passthrough, Content-Length oversized 413, and chunked oversized
behavior (200 empty body due to RateLimiterServlet absorbing BadMessageException).

Clean up SizeLimitHandlerTest: remove 3 redundant testJsonRpcBody* tests
that used BroadCatchServlet (cannot represent real jsonrpc4j chain), rename
TestJsonRpcService to SecondHttpService, remove banner-style ruler comments,
fix stale EchoServlet Javadoc reference, and remove HTML tags from Javadoc.
…nd fix comment attribution

Add getMaxRequestSize()/setMaxRequestSize() to HttpService so tests
use compile-safe accessors instead of Field.setAccessible(true).
Correct comments attributing exception swallowing to RateLimiterServlet
when it is actually jsonrpc4j that silently absorbs the BadMessageException.
…, finally guard

- Replace try/catch/fail pattern with Assert.assertThrows in UtilTest and ArgsTest (4 cases)
- Replace non-ASCII punctuation (→, —) with ASCII (->, -) in newly added test comments
- Hoist originalLimit before outer try in testJsonRpcSizeLimitIntegration so restore
  executes even when start() throws
Align node.http.maxMessageSize and node.jsonrpc.maxMessageSize with the
existing node.rpc.maxMessageSize rule: reject values > Integer.MAX_VALUE
at startup with TronError. Downstream body materialization is int-bounded
(String/byte[]/StringBuilder all cap at Integer.MAX_VALUE), so config
values beyond that produced an ambiguous silent mismatch; fail-fast is
safer than a runtime NegativeArraySizeException or truncation surprise.

Update config.conf docblocks (http/rpc/jsonrpc) to state the full
constraint. Replace the obsolete 2Gi success assertion in
testMaxMessageSizeHumanReadable, add testHttpMaxMessageSizeExceedsIntMax
and testJsonRpcMaxMessageSizeExceedsIntMax mirroring the existing rpc
case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant