(Sorry for the late response, I keep getting sidetracked by other stuff) Is there a reason you're trying to deprecate the URL constructors?
And if we end up not using the URL constructors, then I still think it would be nice to have a test library, since it's easy to forget to add the "[]". Unless we fix up all the existing tests and you'll be sure to catch any future bad uses of the loopback address in URLs in tests :) On Thu, Mar 14, 2019 at 12:19 PM Chris Hegarty <chris.hega...@oracle.com> wrote: > Arthur, > > On 14 Mar 2019, at 17:44, Arthur Eubanks <aeuba...@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/ > jshell> URL u = new URL("http", > InetAddress.getLoopbackAddress().getHostAddress(), 9002, "/") > u ==> http://127.0.0.1:9002/ > jshell> URL u = new URL("http", > InetAddress.getLoopbackAddress().getHostName(), 9002, "/") > u ==> http://localhost:9002/ > > On Thu, Mar 14, 2019 at 9:40 AM Chris Hegarty <chris.hega...@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/ >> >> 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/ (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 >> >