RFR: 8350279: HttpClient: Add a new HttpResponse method to identify connections [v12]

Daniel Fuchs dfuchs at openjdk.org
Thu Apr 10 14:00:58 UTC 2025


On Tue, 8 Apr 2025 19:27:17 GMT, Volkan Yazici <vyazici at openjdk.org> wrote:

>> Adds `HttpResponse::connectionLabel` method that provides an identifier for the connection.
>> 
>> **Implementation note:** The feature is facilitated by `HttpConnection::label`, which should not be confused with `HttpConnection::id`. This distinction is explained in the JavaDoc of both properties.
>
> Volkan Yazici has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Add `@implNote` to state that the built-in is always non-empty

Changes requested by dfuchs (Reviewer).

test/jdk/java/net/httpclient/HttpResponseConnectionLabelTest.java line 171:

> 169:                             String message = "Server[%s] has failed! (connectionKey=%s, responseBody=%s)"
> 170:                                     .formatted(serverId, connectionKey, responseBody);
> 171:                             throw new RuntimeException(message, ioe);

I would recommend logging something here before throwing the exception. For instance calling `ioe.printStackTrace()`. There's not supposed to be one, and if there  is one it's not guaranteed that throwing it will ensure that it gets logged. The client might fail with some other error, or the test may timeout, and we will never know what happened.

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

PR Review: https://git.openjdk.org/jdk/pull/24154#pullrequestreview-2756948977
PR Review Comment: https://git.openjdk.org/jdk/pull/24154#discussion_r2037489181


More information about the net-dev mailing list