8235925: java/net/Socket/HttpProxy.java fails on IPv4 only hosts and other small cleanups
HttpProxy test is fixed to take into account the possibility that the host may be configured with IPv4 only Reviewed-by: chegar
This commit is contained in:
parent
ee5777c700
commit
e16d4a45b0
@ -91,6 +91,10 @@ public class HttpProxy {
|
||||
this.proxyPort = proxyPort;
|
||||
}
|
||||
|
||||
static boolean canUseIPv6() {
|
||||
return IPSupport.hasIPv6() && !IPSupport.preferIPv4Stack();
|
||||
}
|
||||
|
||||
void test() throws Exception {
|
||||
InetSocketAddress proxyAddress = new InetSocketAddress(proxyHost, proxyPort);
|
||||
Proxy httpProxy = new Proxy(Proxy.Type.HTTP, proxyAddress);
|
||||
@ -101,7 +105,7 @@ public class HttpProxy {
|
||||
externalAddresses.add(
|
||||
new InetSocketAddress(InetAddress.getLocalHost(), ss.getLocalPort()));
|
||||
|
||||
if (!"true".equals(System.getProperty("java.net.preferIPv4Stack"))) {
|
||||
if (canUseIPv6()) {
|
||||
byte[] bytes = new byte[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1};
|
||||
var address = InetAddress.getByAddress(bytes);
|
||||
externalAddresses.add(
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8036979 8072384 8044773 8225214 8233296
|
||||
* @bug 8036979 8072384 8044773 8225214 8233296 8234083
|
||||
* @library /test/lib
|
||||
* @requires !vm.graal.enabled
|
||||
* @run main/othervm -Xcheck:jni OptionsTest
|
||||
|
Loading…
Reference in New Issue
Block a user