2362N/A * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * @summary Incoming connections should be subject to timeout 0N/A * @author Adrian Colley 5551N/A * @build TestIface TestImpl TestImpl_Stub 5551N/A * -Dsun.rmi.transport.tcp.readTimeout=5000 ReadTimeoutTest 0N/A/* This test sets a very short read timeout, exports an object, and then 0N/A * connects to the port and does nothing. The server should close the 0N/A * connection after the timeout. If that doesn't happen, the test fails. 0N/A * A background thread does the read. The foreground waits for DELAY*4 0N/A * and then aborts. This should give sufficient margin for timing slop. 169N/A private static final int DELAY =
5000;
// milliseconds 169N/A // Make trouble for ourselves 169N/A // Flaky code alert - hope this is executed before TCPTransport.<clinit> 169N/A // Set the socket factory. 169N/A // Create remote object 169N/A // Export and get which port. 169N/A throw new Error(
"TEST FAILED: export didn't reserve a port(?)");
169N/A // Now, connect to that port 169N/A // Read on the socket in the background 169N/A /** Create a server socket and remember which port it's on. 169N/A * Aborts if createServerSocket(0) is called twice, because then 169N/A * it doesn't know whether to remember the first or second port. 169N/A "Duplicate createServerSocket(0)");
169N/A throw new Error(
"Test aborted (createServerSocket)");
169N/A /** Return which port was reserved by createServerSocket(0). 169N/A * If the return value was 0, createServerSocket(0) wasn't called. 0N/A }
// end class SomeFactory 0N/A }
// end class SomeReader