RMI Connections (in general) should use a timeout on the Socket connect call by default.
JMX connections use RMI and some connection failures never terminate. The hang described in 8316649 is hard to reproduce manually: the description says it can be caused by a firewall that never returns a response. src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPChannel.java has other timeouts but nothing to control the initial Socket connect. Defaulting to a 1 minute timeout on connect has no effect on existing tests for RMI and JMX, and should go unnoticed in applications unless there really is a significant connection delay. Specifying zero for the new System Property sun.rmi.transport.tcp.initialConnectTimeout uses the old code path of a connect with no timeout. I have a test, but it is not realistically usable: although specifying a 1 millisecond timeout will often fail (as expected/desired for the test), it will often pass as the connection happens immediately. ------------- Commit messages: - Ignore negative timeout values. - Make connect timeout static - 8316649: JMX connection timeout cannot be changed and uses the default of 0 (infinite) Changes: https://git.openjdk.org/jdk/pull/16771/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=16771&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8316649 Stats: 21 lines in 1 file changed: 19 ins; 0 del; 2 mod Patch: https://git.openjdk.org/jdk/pull/16771.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/16771/head:pull/16771 PR: https://git.openjdk.org/jdk/pull/16771