JDK-4257513 : Accessing killed remote server which has created process
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.rmi
  • Affected Version: 1.2.2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_nt
  • CPU: x86
  • Submitted: 1999-07-27
  • Updated: 1999-07-27
  • Resolved: 1999-07-27
Related Reports
Duplicate :  
Description

Name: rlT66838			Date: 07/27/99


If I start a remote server, create a separate process in the server, kill the server (ctrl-c) but leave the created process running and tries to access the killed server, the remote method call hangs.

Repro:
1) javac RemoteLauncher.java RemoteLauncherImpl.java Client.java (Source codes provided below.)
2) rmic RemoeteLauncherImpl
3) start rmiregistry
4) start java RemoeteLauncherImpl (The server starts and opens a notepad.)
5) Leave the notepad open and kill the server process (ctrl-c in 'java RemoteLauncherImpl' dos window)
6) java client (Note that the remote method call hangs. Also note that the call comes back with ConnectException once the notepad is closed, which is correct behavior.)

// RemoteLauncher.java
import java.rmi.*;

public interface RemoteLauncher extends Remote
{
	public boolean check() throws RemoteException;
}

// RemoteLauncherImpl.java
import java.rmi.*;
import java.rmi.server.*;
import java.io.*;

public class RemoteLauncherImpl extends UnicastRemoteObject implements RemoteLauncher
{
	public RemoteLauncherImpl() throws RemoteException, SecurityException, IOException
	{
		// create an independent process
		Runtime.getRuntime().exec("cmd /c start notepad");
	}
	
	public boolean check()
	{
		return true;
	}

	public static void main(String[] args) throws Exception
	{
		RemoteLauncherImpl rli = new RemoteLauncherImpl();
		Naming.rebind("rmi://localhost/RemoteLauncher", rli);
		System.out.println("Registered RemoteLauncher.");
	}
}

// Client.java
import java.rmi.*;

public class Client
{
	public static void main(String args[]) throws Exception {
		RemoteLauncher rl = (RemoteLauncher)Naming.lookup("rmi://localhost/RemoteLauncher");
		System.out.println("rl.check()" + rl.check());
	}
}

Desirable behavior:
The remote call should come back with ConnectException even if there is a running process created by the server.

C:\home\java\launcher_hang_repro>%jv% -version
java version "1.2.2"
Classic VM (build JDK-1.2.2-W, native threads, symcjit)

C:\home\java\launcher_hang_repro>%jv% -fullversion
java.exe full version "JDK-1.2.2-W"
(Review ID: 93116) 
======================================================================

Comments
WORK AROUND Name: rlT66838 Date: 07/27/99 I used setSoTimeout() in the client's socket so it can time out if the hang happens. (The situation here is that the caller doesn't know about the server's death.) However, setting timeout to low value caused other undesirable problems (such as premature timeout for access to other remote servers). I'd really like to know if there is a better work-around for this problem. ======================================================================
11-06-2004

EVALUATION This is a (unfortunate) symptom of 4197666. peter.jones@East 1999-07-27
27-07-1999