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

Volkan Yazici vyazici at openjdk.org
Tue Nov 25 21:04:42 UTC 2025


On Tue, 25 Nov 2025 13:05:38 GMT, Daniel Fuchs <dfuchs 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/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?

This is a fast-path to exit early if `Content-Length` is present and cannot be parsed into a `long`. AFAICT,

- The author was already either aware of the missing `Content-Length` checks, or suspecting that. Therefore he introduced this rudimentary check.
- This concern is only relevant for `Content-Length` consumers, where we thoroughly validate the value at each use-site in this PR.

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

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


More information about the net-dev mailing list