RFR: 8209137: Add ability to bind to specific local address to HTTP client [v17]

Jaikiran Pai jpai at openjdk.java.net
Tue May 10 12:56:01 UTC 2022


On Mon, 9 May 2022 13:31:38 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

>> Jaikiran Pai has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 37 commits:
>> 
>>  - Merge latest from master branch
>>  - add a @build to force jtreg to show consistent test results and add the relevant permissions for security manager testing
>>  - Change the new API to accept an InetAddress instead of an InetSocketAddress, after inputs from Michael, Daniel and others
>>  - Merge latest from master
>>  - Implement HttpServerAdapters in test as suggested by Daniel
>>  - fix check when security manager is enabled
>>  - Add a unit test for the new HttpClient.Builder.localAddress method
>>  - Implement Daniel's suggestion - only support InetSocketAddress with port 0
>>  - Merge latest from master branch
>>  - Merge latest from master branch
>>  - ... and 27 more: https://git.openjdk.java.net/jdk/compare/b490a58e...d4a19dea
>
> src/java.net.http/share/classes/java/net/http/HttpClient.java line 398:
> 
>> 396:          *
>> 397:          * @implSpec If the {@link #localAddress(InetAddress) local address} is a non-null
>> 398:          * <i>Internet Protocol</i> address and a security manager is installed, then
> 
> Here and in the @throws bellow we could now remove mention of `<i>Internet Protocol</i>`.
> For instance, here we could say 
> 
> ... is a non-null address and a security ...

Done. Updated this and the other javadoc comment to follow this suggestion.

> test/jdk/java/net/httpclient/HttpClientBuilderTest.java line 274:
> 
>> 272:         // setting null should work fine
>> 273:         builder.localAddress(null);
>> 274:         builder.localAddress(InetAddress.getLoopbackAddress());
> 
> We probably also need a MockHttpClientBuilder to test the behaviour of the default implementation (check that it throws UOE).

I've now updated this PR to add a new test method which tests the default method implementation of `localAddress`.

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

PR: https://git.openjdk.java.net/jdk/pull/6690


More information about the net-dev mailing list