RFR(s): 8023541 Race condition in rmid initialization

Stuart Marks stuart.marks at oracle.com
Thu Jan 30 06:54:14 UTC 2014


On 1/29/14 8:50 PM, Tristan Yan wrote:
> Looks like in you new webrev.  The wait will continue to go loop until
> systemStub is not null. If it’s what you meant to do that?

Yes. In the previous webrev, systemStub started off as null and made a single 
transition to non-null. The boolean 'initialized' started off as false and made 
a single transition to true, at the same time. If you set aside the issue of 
systemStub being final (which I've removed in this webrev) these states are 
redundant. That is,

     systemStub == null    <==>    initialized == false
     systemStub != null    <==>    initialized == true

(Where <==> is read as "if and only if" meaning that the implication goes both 
ways.)

The while-loop in the old webrev was

     while (!initialized)

which is the same as

     while (initialized == false)

Therefore, the loop condition can be replaced with

     while (systemStub == null)

and the initialized field can be removed.

Restated in perhaps a more intuitive way, the bug was that lookup() sometimes 
returned null. So the condition on systemStub that we want to reach before 
returning from getSystemStub() is that systemStub be non-null. To do this we 
have to write the inverse of the condition in the while loop. Thus, we want 
systemStub to be non-null, so we have to keep waiting while it is null.

s'marks



More information about the core-libs-dev mailing list