Reputation:
I have an RMI interface that has a method with a void return.
For example:
public interface IDummy {
public void foo() throws RemoteException;
}
I then create a stub via UnicastRemoteObject and export that stub.
Is it required in the RMI spec that calls to foo
block until foo
returns?
It seems like you would have to block in case foo
throws an exception.
Even though the return type is void, foo
might throw an exception which would have to be transported across as RMI is able to transfer arbitrary exceptions over.
However, I have heard conflicting reports that RMI does not have to block for a void return case.
Does anyone have a definitive answer? I have already looked over the RMI spec and it does not seem to address this issue. Some people claim that it does not block.
In addition, I have read through the JDK source code and it definitely blocks even when the return value is void.
Upvotes: 2
Views: 1536
Reputation: 310980
Is it required in the RMI spec that calls to foo block until foo returns
It is required that all method calls block until they return. Nothing special about RMI here.
Upvotes: 0
Reputation: 692043
The spec says:
When a stub's method is invoked, it does the following:
- initiates a connection with the remote JVM containing the remote object,
- marshals (writes and transmits) the parameters to the remote JVM,
- waits for the result of the method invocation,
- unmarshals (reads) the return value or exception returned, and
- returns the value to the caller.
(emphasis mine)
So yes, it must block.
Upvotes: 5