RFR: 8369595: HttpClient: HttpHeaders.firstValueAsLong failures should be converted to ProtocolException [v2]

Daniel Fuchs dfuchs at openjdk.org
Tue Nov 25 13:14:43 UTC 2025


On Mon, 24 Nov 2025 20:45:27 GMT, Volkan Yazici <vyazici at openjdk.org> wrote:

>> Add guards against `HttpHeaders::firstValueAsLong` failures. `H3MalformedResponseTest` is overhauled – migrated to JUnit, reinforced with exception type tests, etc. – but not all `firstValueAsLong` changes are verified with new additional tests. `test/jdk/java/net/httpclient/` tests still do pass.
>
> Volkan Yazici has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Address review remarks

src/java.net.http/share/classes/jdk/internal/net/http/Http3ExchangeImpl.java line 1289:

> 1287:         // Read & validate `Content-Length`
> 1288:         long clen = readContentLength(
> 1289:                 promiseHeaders, "illegal push headers for pushId=%s: ".formatted(pushId), 0);

Let's keep -1 as default value to represent no Content-length header, even though not strictly necessary in this context.

src/java.net.http/share/classes/jdk/internal/net/http/Stream.java line 1786:

> 1784:                    sure code up the stack handles NFE correctly. */
> 1785:                 responseHeaders.firstValueAsLong("content-length");
> 1786: 

We no longer check here that content-length is a number if present. Has that become unecessary?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28431#discussion_r2559898415
PR Review Comment: https://git.openjdk.org/jdk/pull/28431#discussion_r2559924070


More information about the net-dev mailing list