Thanks Roger, sorry for that I missed your response. (most of time I
focus on mail send to/cc me :) )
On 2019/10/15 10:29 PM, Roger Riggs wrote:
Hi,
1. Replace the creation of the Registry with
TestLibrary.crateRegistryOnEphemeralPort
and call TestLibrary.getRegistryPort to get the port number.
The intent of the test is still satisified without the timing/port
allocation issues.
For this test, it failed only after unexportObject is called and port is
not freed in time or occupied again by others.
So it would be fine to use crateRegistryOnEphemeralPort but will not
help to resolve this issue.
2. Another approach to testing if the port is in use would be to
assume its still active and do a registry.lookup("xxx").
The response be NotBoundException if the registry is still alive
or will be a RemoteException indicating the port is closed.
If some other application has grabbed the port, some other exception
RemoteException cause will be thrown.
I'm not sure if RemoteException equals to the port has been closed by
the registry.
Based on API doc, "|RemoteException
<https://docs.oracle.com/en/java/javase/12/docs/api/java.rmi/java/rmi/RemoteException.html>|-
if remote communication with the registry failed; if exception is
a|ServerException|containing an|AccessException|, then the registry
denies the caller access to perform this operation", in my
understanding, a) "port is closed" and b) "others grab the port again"
will cause RemoteException, but RemoteException does not mean it's in
just one of the 2 situations a) and b).
Thank you
-Hamlin