Regarding 8220575: Correctly format test URI's that contain a retrieved IPv6 address

Chris Hegarty chris.hegarty at oracle.com
Thu Mar 14 19:19:11 UTC 2019


Arthur,

> On 14 Mar 2019, at 17:44, Arthur Eubanks <aeubanks at google.com> wrote:
> 
> Most of these eventually turn the String into a URL, so using a URL directly should work?

URL constructors will work, but I would prefer to not add any more
usages of these than we already have. I plan to start a discussion about
the possibility of deprecating these constructors in the not too distant
future.

-Chris.

> jshell> URL u = new URL("http", "::1", 9002, "/")
> u ==> http://[::1]:9002/ <http://[::1]:9002/>
> jshell> URL u = new URL("http", InetAddress.getLoopbackAddress().getHostAddress(), 9002, "/")
> u ==> http://127.0.0.1:9002/ <http://127.0.0.1:9002/>
> jshell> URL u = new URL("http", InetAddress.getLoopbackAddress().getHostName(), 9002, "/")
> u ==> http://localhost:9002/ <http://localhost:9002/>
> On Thu, Mar 14, 2019 at 9:40 AM Chris Hegarty <chris.hegarty at oracle.com <mailto:chris.hegarty at oracle.com>> wrote:
> It's just a hack, but enough to get me started so I can asses some of
> what is needed to support running the tests on an IPv6-only environment.
> 
>   http://cr.openjdk.java.net/~chegar/ipv6-only-hack/ <http://cr.openjdk.java.net/~chegar/ipv6-only-hack/>
> 
>   My /etc/hosts file has entries for `localhost` and the _host_, that
>   return `::1`.
> 
> This is enough to get started, but it will run out of road quite soon.
> And it will break some things. Let's work towards getting a better
> solution.
> 
> Also, we will need test library support for determining whether the
> platform supports: 1) IPv4, or 2) IPv6, or 3) IPv4&IPv6. I filed 8220673
> [1] to tracks this.
> 
> ---
> 
> Regarding what to do with URL's in test. I tried a few different
> approaches, I am leaning towards:
> 
>      String host = loopbackAddress.getHostAddress();
>      if (host.contains(":"))
>          host = "[" + host + "]";
> 
> Since it:
>  1) is relatively short and concise, and
>  2) ensures, in many cases, that the client and server use the same
>     IP address, and
>  3) clearly shows the actual IP protocol in use, e.g.
>     http://[0:0:0:0:0:0:0:1]:46009/zero/xxyy
> 
> A sample of some tests that have been updated as above:
>   http://cr.openjdk.java.net/~chegar/8220575/webrev.0.1/ <http://cr.openjdk.java.net/~chegar/8220575/webrev.0.1/> (not too bad!)
> 
> -Chris.
> 
> P.S. I ran into an implementation bug and filed, 8220663: "Incorrect
> handling of IPv6 addresses in Socket(Proxy.HTTP)" - the fix is straight
> forward.
> 
> [1] https://bugs.openjdk.java.net/browse/JDK-8220673 <https://bugs.openjdk.java.net/browse/JDK-8220673>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/net-dev/attachments/20190314/a17ddf08/attachment-0001.html>


More information about the net-dev mailing list