JDK-8073080 : TEST_BUG: sun/rmi/transport/tcp/DeadCachedConnection.java fails due to "ConnectException: Connection refused to host"
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.rmi
  • Affected Version: 7u91,8u66,9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2015-02-12
  • Updated: 2017-01-17
  • Resolved: 2016-12-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b151Fixed
Related Reports
Relates :  
Relates :  
Description
This test failure was spotted in a JDK9 Aurora Adhoc job:

sun/rmi/transport/tcp/DeadCachedConnection.java

    This test failed due to "java.rmi.ConnectException: Connection refused to host: 10.128.128.51;
    nested exception is: java.net.ConnectException: Connection refused".

    I almost invalidated this test as an "infra" issue, but this test seems to be
    expecting failure because we're intentionally trying to use a dead cached
    connection. Perhaps this is just a failure mode that this test was not
    expecting.

Here is a snippet from the .jtr file:

Trying to use registry in spite of stale cache...
java.rmi.ConnectException: Connection refused to host: 10.128.128.51; nested exception is: 
	java.net.ConnectException: Connection refused
	at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
	at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:214)
	at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:200)
	at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:342)
	at sun.rmi.registry.RegistryImpl_Stub.list(Unknown Source)
	at DeadCachedConnection.main(DeadCachedConnection.java:88)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.sun.javatest.regtest.MainWrapper$MainThread.run(MainWrapper.java:94)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.ConnectException: Connection refused
	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:591)
	at java.net.Socket.connect(Socket.java:540)
	at java.net.Socket.<init>(Socket.java:436)
	at java.net.Socket.<init>(Socket.java:213)
	at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
	at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:144)
	at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
	... 11 more

JavaTest Message: Test threw exception: java.rmi.ConnectException: Connection refused to host: 10.128.128.51; nested exception is: 
	java.net.ConnectException: Connection refused
JavaTest Message: shutting down test

STATUS:Failed.`main' threw exception: java.rmi.ConnectException: Connection refused to host: 10.128.128.51; nested exception is: java.net.ConnectException: Connection refused

RULE sun/rmi/transport/tcp/DeadCachedConnection.java Exception java.net.ConnectException: Connection refused

RULE sun/rmi/transport/tcp/DeadCachedConnection.java Exception java.rmi.ConnectException: Connection refused to host: ...; nested exception is: java.net.ConnectException: Connection refused


Comments
similar issue as JDK-8025199, will apply similar fix
20-12-2016

similar issue can be reproduced by applying below patch to test: diff -r 63e82d0eb4f6 test/sun/rmi/transport/tcp/DeadCachedConnection.java --- a/test/sun/rmi/transport/tcp/DeadCachedConnection.java Wed Dec 14 19:23:08 2016 -0800 +++ b/test/sun/rmi/transport/tcp/DeadCachedConnection.java Thu Dec 15 22:52:36 2016 -0800 @@ -59,15 +59,27 @@ import java.rmi.registry.*; import java.rmi.server.*; +import java.net.InetSocketAddress; +import java.nio.channels.ServerSocketChannel; + public class DeadCachedConnection { - static public final int regport = TestLibrary.getUnusedRandomPort(); + static public final int regport = 60003; static public void main(String[] argv) throws Exception { + + ServerSocketChannel ssc = ServerSocketChannel.open(); + System.err.println("==== Restart a socket server at port " + regport); + ssc.socket().bind(new InetSocketAddress(regport)); + ssc.configureBlocking(false); + ssc.accept(); + // establish the registry (we hope) System.err.println ("Starting registry on port " + regport); DeadCachedConnection.makeRegistry(regport); + ssc.close(); + // Get a handle to the registry Registry reg = null; System.err.println ("Locating just-started registry...");
16-12-2016

Same test but different failure mode as JDK-8157777.
26-05-2016

The test has a fixed timeout. The test code should be retrofitted to using the RMI test library, which has retry logic, and which also will scale with the timeout factor provided by the framework.
31-08-2015