2362N/A * Copyright (c) 1998, 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 RMI UnmarshallException, interaction on stopping a thread. 0N/A * @summary RuntimeExceptions can corrupt call connections that may be reused. 0N/A * @author Laird Dornin 0N/A * @library ../../../testlibrary 5551N/A * @build TestLibrary CheckUnmarshal CheckUnmarshalOnStopThread_Stub 5551N/A * PoisonPill RuntimeExceptionParameter 169N/A * Description for 4118600: 0N/A * If an rmi call thread is stopped while unmarshalling a return 0N/A * value), java.lang.ThreadDeath will be thrown during 0N/A * UnicastRef.invoke(...). If rmi handles the Error properly, the 0N/A * remote method connection will not be reused. Otherwise the 0N/A * connection can be freed and reused in a corrupted state, which will 0N/A * lead to the throwing of an UnmarshalException the next time the 0N/A * connection is used. 0N/A * To test RMI Error handling, the test invokes the remote call, 0N/A * getPoisonPill, a number of times. This method returns an object 0N/A * which throws an Error on return value deserialization (from its 0N/A * readObject method). If RMI handles the error correctly, another 0N/A * remote call, ping, should execute correctly (i.e. with no 0N/A * exceptions). The test fails if the ping method throws an 0N/A * UnmarshalException. 0N/A * The old way that the test used to operate: 0N/A * Iterate a large number of times: each iteration spawns a thread 0N/A * that makes multiple rmi calls, sleep for 10 milliseconds, then stop 0N/A * the thread that is making the rmi calls (hopefully during return 0N/A * value Unmarshalling). 0N/A * Count the number of UnmarshalExceptions that occur during test 0N/A * iterations. If this number is > 10, then the test fails. 0N/A * Note: Even if rmi is catching java.lang.ThreadDeath properly, other 0N/A * types of exceptions (often related to monitor state, etc.) can 0N/A * occur. This test is only written to track UnmarshalExceptions; 169N/A * Description for 4177704: 0N/A * Similar situation as for 4177704 except that instead of just 0N/A * ensuring that RMI properly handles Errors, the second part of the 0N/A * test ensures that RMI deals with RuntimeExceptions correctly. 0N/A * Test also ensures that call connections are freed without reuse 0N/A * when RuntimeExceptions are thrown during the marshalling of call 0N/A * parameters. An object that throws a RuntimeException in its 0N/A * writeObject method helps to carry out this part of the test. 169N/A * remote object implementation 169N/A // will never be called 169N/A "4118600 and 4177704\n");
169N/A // make sure that RMI will free connections appropriately 169N/A // under several situations: 169N/A // when Errors are thrown during parameter unmarshalling 169N/A // when RuntimeExceptions are thrown during parameter unmarshalling 169N/A // when RuntimeExceptions are thrown during parameter marshalling 169N/A "runtime exceptions thrown during " +
169N/A "parameter marshalling");
169N/A (
"\nsuccess: CheckUnmarshalOnStopThread test passed ");
169N/A // invoke a remote call that will corrupt a call connection 169N/A // that will not be freed (if the bug is not fixed) 169N/A for (
int i =
0 ; i <
250 ; i++) {
169N/A // expect an Error from call unmarshalling, ignore it 169N/A // " RuntimeException " 169N/A "unmarshal exceptions\n\n");
169N/A // make sure that the object goes away