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

Volkan Yazici vyazici at openjdk.org
Tue Nov 25 21:10:48 UTC 2025


On Tue, 25 Nov 2025 11:52:09 GMT, Daniel Jeliński <djelinski at openjdk.org> wrote:

>> 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/MultiExchange.java line 374:
> 
>> 372:         // Check `Transfer-Encoding`
>> 373:         var transferEncoding = headers.firstValue("Transfer-Encoding").orElse(null);
>> 374:         if (transferEncoding != null) {
> 
> use `isPresent` instead of `orElse(null) != null`

Changed as requested in f01368f08c9.

> src/java.net.http/share/classes/jdk/internal/net/http/Stream.java line 1822:
> 
>> 1820:     }
>> 1821: 
>> 1822:     private static int readStatusCode(HttpHeaders headers, String errorPrefix) throws ProtocolException {
> 
> There's a similar piece of code for HTTP3 [here](https://github.com/openjdk/jdk/blob/b491c9bc98a8da0a1d913e85673087e1b929cb3d/src/java.net.http/share/classes/jdk/internal/net/http/Http3Stream.java#L610-L624); do you think you could merge them?

This was the case, but apparently got lost during refactoring. In dfbb64913f0,

- I've moved `readStatusCode` to `Utils`
- Replaced `i < 0` check of `readStatusCode` with `i < 100 || i > 999`
- Used `readStatusCode` in `Http3Stream`

Searched for `":status"` (and `Content-Length`) in `src/java.net.http` and could not find any other hits.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28431#discussion_r2561404031
PR Review Comment: https://git.openjdk.org/jdk/pull/28431#discussion_r2561404220


More information about the net-dev mailing list