On 30/01/2014 09:09, Daniel Fuchs wrote:
Hi Stuart,

I wonder whether you should replace the assert in the
constructor by an explicit null check:

-  assert systemStub != null
+ if (systemStub == null) throw new NullPointerException();

The reason I see is that before your change, an object constructed
with a null systemStub would have sooner or later failed in NPE.
Now with your change, an object constructed with a null system
stub will block - waiting forever for system stub to become not
null.
I suspect the system stub can never be null but I agree it should be checked before creating the RegistryImpl. One way to do that is by going through another constructor, something like this:

    private SystemRegistryImpl(int port,
                               RMIClientSocketFactory csf,
                               RMIServerSocketFactory ssf,
                               ActivationSystem systemStub,
                               Void unused) throws RemoteException {
        super(port, csf, ssf);
        synchronized (this) {
            this.systemStub = systemStub;
            notifyAll();
        }
    }

    SystemRegistryImpl(int port,
                       RMIClientSocketFactory csf,
                       RMIServerSocketFactory ssf,
ActivationSystem systemStub) throws RemoteException {
        this(port, csf, ssf, Objects.requireNonNull(systemStub), null);
    }

but maybe that it too subtle.

-Alan

Reply via email to