Name: nt126004 Date: 12/19/2001
java version "1.4.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b84)
Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed mode)
Full Operating System Version :
Microsoft Windows 2000 [Version 5.00.2195]
service pack 2
A description of the problem :
When an client thread is blocked in a monitor on a remote
server, interrupting the client thread has no effect i.e.
the thread remains blocked in the call. On Solaris, the
client thread is unblocked but it throws a
java.rmi.UnmarhsallException instead of an
InterruptedException.
Steps to follow to reproduce the problem :
1. compile the code below
2. generate a stub for the Server using rmic
3. start the rmiregistry "start /b rmiregistry 36098"
4. start the server "start /b java Server"
5. start the client "java Client"
Expected versus actual behavoir :
expected output:
Server accepting block() call...
Interrupting mainThread...
mainThread caught exception: java.lang.InterruptedException
mainThread exiting
actual output (Win2K):
Server accepting block() call...
Interrupting mainThread...
actual output (Solaris "SunOS sunshine.research.att.com 5.8
Generic_108528-11 sun4u sparc SUNW,Ultra-60"):
Server accepting block() call...
Interrupting mainThread...
mainThread caught exception: java.rmi.UnmarshalException:
Error unmarshaling return header; nested exception is:
java.io.EOFException
mainThread exiting
This bug can be reproduced always.
---------- Begin Source ----------
==================
RemoteServer.java:
==================
import java.rmi.*;
public interface RemoteServer extends Remote {
public void block() throws InterruptedException,
RemoteException;
}
===========
Server.java
===========
import java.rmi.*;
import java.rmi.server.*;
public class Server extends UnicastRemoteObject implements RemoteServer {
public static final void main(String[] argv) {
try {
// create an instance of ourselves and register it
Naming.rebind("//:36098/server", new Server());
} catch (Exception e) {
System.out.println("Server unable to register: " + e);
System.exit(1);
}
}
public Server() throws RemoteException {}
public void block() throws RemoteException, InterruptedException {
System.out.println("Server accepting block() call...");
synchronized (this) {
// caller blocks indefinitely
this.wait();
}
}
}
===========
Client.java
===========
import java.rmi.*;
import java.rmi.server.*;
public class Client {
public static final void main(String[] argv) {
// lookup server
RemoteServer server = null;
try {
server = (RemoteServer) Naming.lookup("rmi://:36098/server");
} catch (Exception e) {
System.out.println("Unable to lookup server: " + e);
System.exit(1);
}
final Thread mainThread = Thread.currentThread();
// spawn thread to interrupt me after timeout
new Thread(new Runnable() {
public void run() {
try {
Thread.sleep(10000);
} catch
(InterruptedException e) {}
System.out.println("Interrupting mainThread...");
mainThread.interrupt();
}
}).start();
// call server and block
try {
server.block();
} catch (Exception e) {
System.out.println("mainThread caught exception: " + e);
}
System.out.println("mainThread exiting");
}
}
---------- End Source ----------
(Review ID: 137364)
======================================================================