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

Jaikiran Pai jpai at openjdk.org
Wed Apr 2 11:27:52 UTC 2025


On Tue, 1 Apr 2025 19:11:02 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:
> 
>   Apply review suggestions

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

> 81: 
> 82:     // Start with a fresh client having no connections in the pool
> 83:     @AutoClose

I hadn't come across this JUnit Jupiter annotation before. Reading through https://junit.org/junit5/docs/current/user-guide/#writing-tests-built-in-extensions-AutoClose it appears to be a convenience mechanism for managing closing of the resources at the "right time". That doc states:

> Specifically, if the test class is configured with @TestInstance(Lifecycle.PER_METHOD) semantics, a non-static @AutoClose field will be closed after the execution of each test method, test factory method, or test template method. However, if the test class is configured with @TestInstance(Lifecycle.PER_CLASS) semantics, a non-static @AutoClose field will not be closed until the current test class instance is no longer needed

Do you know what test class lifecycle is configured for test classes like this one when launched through jtreg?

Typically, we just use very basic JUnit constructs in the tests in the JDK repo to make it simpler to follow these tests, even if it means a bit more verbose code like having a method annotated with `@BeforeEach`/`@AfterEach` to do construction/clean up like this.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24154#discussion_r2024629463


More information about the net-dev mailing list