RFR: 8209137: Add ability to bind to specific local address to HTTP client [v17]
Daniel Fuchs
dfuchs at openjdk.java.net
Mon May 9 14:01:04 UTC 2022
On Mon, 9 May 2022 07:52:29 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:
>> This change proposes to implement the enhancement noted in https://bugs.openjdk.java.net/browse/JDK-8209137.
>>
>> The change introduces a new API to allow applications to build a `java.net.http.HTTPClient` configured with a specific local address that will be used while creating `Socket`(s) for connections.
>
> 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
Changes requested by dfuchs (Reviewer).
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 ...
src/java.net.http/share/classes/java/net/http/HttpClient.java line 411:
> 409: * the {@link #localAddress(InetAddress) local address} is an
> 410: * <i>Internet Protocol</i> address and the
> 411: * security manager's {@link SecurityManager#checkListen checkListen}
```
... has been installed and the security manager's {@link SecurityManager#checkListen checkListen} ...
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).
-------------
PR: https://git.openjdk.java.net/jdk/pull/6690
More information about the net-dev
mailing list