eclipse-ee4j / eclipse-ee4j/jersey

InboundMessageContext.getLength() blows up for CONTENT_LENGTH that exceed Integer limits

Open
#4,984 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

We have a use case where we are using the jersey client (@ 2.33 currently) to issue a Http HEAD to an endpoint that hosts files for download.
For files sizes that exceed a threshold of 2 Gigs approx - the maximum Integer limit (2147483647) - we start to see NumberFormatExceptions.

This issue seems to occur during the CONTENT_LENGTH parsing here :
https://github.com/eclipse-ee4j/jersey/blob/9bb2e8dffe2ee307dde151b35f3b98fc81782d4c/core-common/src/main/java/org/glassfish/jersey/message/internal/InboundMessageContext.java#L435

Caused by: java.lang.NumberFormatException: For input string: \"4294967296\"\n\t
at java.base/java.lang.NumberFormatException.forInputString(Unknown Source)\n\t
at java.base/java.lang.Integer.parseInt(Unknown Source)\n\t
at java.base/java.lang.Integer.parseInt(Unknown Source)\n\t
at org.glassfish.jersey.message.internal.InboundMessageContext$4.apply(InboundMessageContext.java:435)\n\t... 34 common frames omitted\n"

Checking if there a reason why the CONTENT_LENGTH values were constrained to Integers instead of Longs..

Contributor guide

Open the contributing guide

Research direction

Start at core-common/src/main/java/org/glassfish/jersey/message/internal/InboundMessageContext.java around line 435, where CONTENT_LENGTH is parsed, and inspect related message-context tests. Reproduce the failure with a value such as 4294967296, then verify that valid CONTENT_LENGTH values beyond Integer limits are handled without a NumberFormatException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.