JDK-8132520 : Socket to literal ipv6 address fails
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 7u79
  • Priority: P3
  • Status: Resolved
  • Resolution: Duplicate
  • OS: os_x
  • CPU: x86
  • Submitted: 2015-05-19
  • Updated: 2018-10-19
  • Resolved: 2018-10-19
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Darwin 2guns.local 14.3.0 Darwin Kernel Version 14.3.0: Mon Mar 23 11:59:05 PDT 2015; root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64

EXTRA RELEVANT SYSTEM CONFIGURATION :
a working ipv6 network connection

A DESCRIPTION OF THE PROBLEM :
This code:

 // www.google.com address
InetAddress adr = InetAddress.getByName("2a00:1450:4008:800::1010");
Socket socket = new Socket(adr, 22);

throws this:
java.net.NoRouteToHostException: No route to host
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:589)
	at java.net.Socket.connect(Socket.java:538)
	at java.net.Socket.<init>(Socket.java:434)
	at java.net.Socket.<init>(Socket.java:244)

This only happens on macos x not on linux or windows. And please don't ask about that if
my network is work, it is, i proofed it with telnet. There are no socks or proxies configured, 
i stepped with the debugger to the nativ connect call and this throws the exception but receives
the right data (address,port)
It only happens if a literal ipv6 address is used. 

REGRESSION.  Last worked in version 8u25

ADDITIONAL REGRESSION INFORMATION: 
it also failed on macos with jre 7_45

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
package test;

import java.net.InetAddress;
import java.net.Socket;

public class Test {
	public static void main(String[] args) throws Exception {
                // www.google.com address
		InetAddress adr = InetAddress.getByName("2a00:1450:4008:800::1010");
		Socket socket = new Socket(adr, 80);
        }
}


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
no exception
ACTUAL -
java.net.NoRouteToHostException: No route to host
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:589)
	at java.net.Socket.connect(Socket.java:538)
	at java.net.Socket.<init>(Socket.java:434)
	at java.net.Socket.<init>(Socket.java:244)


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package test;

import java.net.InetAddress;
import java.net.Socket;

public class Test {
	public static void main(String[] args) throws Exception {
                // www.google.com address
		InetAddress adr = InetAddress.getByName("2a00:1450:4008:800::1010");
		Socket socket = new Socket(adr, 80);
        }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
no known, i try a could of ipv6 related options, no difference.


Comments
removing the regression label. This seems to be an issue on all JDK os_x versions that we've shipped. confirmed that my mac test box can resolve the IPv6 address but JDK doesn't get that far. jprtxxx@xxab077:/tmp> nslookup 2a00:1450:4008:800::1010 Server: xx.xx.xx.41 Address: xx.xx.xx41#53 Non-authoritative answer: 0.1.0.1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.0.8.0.0.4.0.5.4.1.0.0.a.2.ip6.arpa name = ber01s08-in-x10.1e100.net. Authoritative answers can be found from: 0.5.4.1.0.0.a.2.ip6.arpa nameserver = ns1.google.com. 0.5.4.1.0.0.a.2.ip6.arpa nameserver = ns3.google.com. 0.5.4.1.0.0.a.2.ip6.arpa nameserver = ns2.google.com. 0.5.4.1.0.0.a.2.ip6.arpa nameserver = ns4.google.com. ns1.google.com internet address = 216.239.32.10 ns4.google.com internet address = 216.239.38.10 ns3.google.com internet address = 216.239.36.10 ns2.google.com internet address = 216.239.34.10 jprtxxx@xxab077:/tmp> /java/re/jdk/8/latest/binaries/macosx-x64/bin/java Test Exception in thread "main" java.net.NoRouteToHostException: No route to host at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) dtruss not showing the connect call attempt. Must check out other strace alternatives.
06-08-2015