17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* @test 25 * @bug 4322806 26 * @summary When an RMI (JRMP) connection is made to a TCP address that is 27 * listening, so the connection is accepted, but the server never responds 28 * to the initial JRMP handshake (nor does it terminate the connection), 29 * the client should not hang forever; instead, it should throw an exception 30 * after a reasonable timeout interval. The exception should be a 31 * java.rmi.ConnectException or ConnectIOException, not a MarshalException, 32 * because it should be clear that no partial call execution has occurred at 33 * this point (because no data for the invocation has yet been written). 34 * @author Peter Jones 35 * 36 * @library ../../testlibrary 37 * @build TestLibrary 38 * @run main/othervm HandshakeTimeout 39 */ 40 41 import java.net.ServerSocket; 42 import java.rmi.ConnectException; 43 import java.rmi.ConnectIOException; 44 import java.rmi.MarshalException; 45 import java.rmi.registry.LocateRegistry; 46 import java.rmi.registry.Registry; 47 48 public class HandshakeTimeout { 49 50 private static final int PORT = TestLibrary.getUnusedRandomPort(); 51 private static final int TIMEOUT = 10000; 52 53 public static void main(String[] args) throws Exception { 54 55 System.setProperty("sun.rmi.transport.tcp.handshakeTimeout", 56 String.valueOf(TIMEOUT / 2)); | 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* @test 25 * @bug 4322806 26 * @summary When an RMI (JRMP) connection is made to a TCP address that is 27 * listening, so the connection is accepted, but the server never responds 28 * to the initial JRMP handshake (nor does it terminate the connection), 29 * the client should not hang forever; instead, it should throw an exception 30 * after a reasonable timeout interval. The exception should be a 31 * java.rmi.ConnectException or ConnectIOException, not a MarshalException, 32 * because it should be clear that no partial call execution has occurred at 33 * this point (because no data for the invocation has yet been written). 34 * @author Peter Jones 35 * 36 * @library ../../testlibrary 37 * @modules java.rmi/sun.rmi.registry 38 * java.rmi/sun.rmi.server 39 * java.rmi/sun.rmi.transport 40 * java.rmi/sun.rmi.transport.tcp 41 * @build TestLibrary 42 * @run main/othervm HandshakeTimeout 43 */ 44 45 import java.net.ServerSocket; 46 import java.rmi.ConnectException; 47 import java.rmi.ConnectIOException; 48 import java.rmi.MarshalException; 49 import java.rmi.registry.LocateRegistry; 50 import java.rmi.registry.Registry; 51 52 public class HandshakeTimeout { 53 54 private static final int PORT = TestLibrary.getUnusedRandomPort(); 55 private static final int TIMEOUT = 10000; 56 57 public static void main(String[] args) throws Exception { 58 59 System.setProperty("sun.rmi.transport.tcp.handshakeTimeout", 60 String.valueOf(TIMEOUT / 2)); |