RFR(s): 8023541 Race condition in rmid initialization
Alan Bateman
Alan.Bateman at oracle.com
Thu Jan 30 14:23:21 UTC 2014
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
More information about the core-libs-dev
mailing list