RFR: 8369595: HttpClient: HttpHeaders.firstValueAsLong failures should be converted to ProtocolException [v5]
Daniel Fuchs
dfuchs at openjdk.org
Mon Dec 1 10:55:13 UTC 2025
On Wed, 26 Nov 2025 10:39:20 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:
>
> Introduce dangling `firstValueAsLong("content-length")` calls back
Changes requested by dfuchs (Reviewer).
src/java.net.http/share/classes/jdk/internal/net/http/Http1Response.java line 338:
> 336: } catch (ProtocolException pe) {
> 337: cf.completeExceptionally(pe);
> 338: return cf;
We're not going to read the body if we return here, so I think we should close the connection with the ProtocolException `pe` before returning the completable future `cf`. Otherwise - the connection will remained unclosed and out of the pool until we close the client.
src/java.net.http/share/classes/jdk/internal/net/http/Http3Stream.java line 630:
> 628: finalResponse = true;
> 629: } else {
> 630: assert responseCode >= 100 && responseCode <= 200 : "unexpected responseCode: " + responseCode;
Can we keep the assert?
-------------
PR Review: https://git.openjdk.org/jdk/pull/28431#pullrequestreview-3524324264
PR Review Comment: https://git.openjdk.org/jdk/pull/28431#discussion_r2576552862
PR Review Comment: https://git.openjdk.org/jdk/pull/28431#discussion_r2576571136
More information about the net-dev
mailing list