RFR(s): 8023541 Race condition in rmid initialization

Peter Levart peter.levart at gmail.com
Wed Jan 29 10:22:12 UTC 2014


Hi Stuart,

My eye was caught by the following new method:

  328         private synchronized void awaitInitialized() {
  329             try {
  330                 while (!initialized) {
  331                     wait();
  332                 }
  333             } catch (InterruptedException ie) {
  334                 Thread.currentThread().interrupt();
  335             }
  336         }



...if the thread calling this method is interrupted while waiting, it 
will set the interrupted status of the thread back, but will terminate 
the waiting loop. So the initialization race is still possible. Why not 
wait until initialized like:


boolean interrupted = false;
while (!initialized) {
     try {
         wait();
     } catch (InterruptedException ie) {
         interrupted = true;
     }
}
if (interrupted) {
Thread.currentThread().interrupt();
}


Regards, Peter


boolean interrupted = false;
On 01/29/2014 07:51 AM, Stuart Marks wrote:
> Hi all,
>
> Please review this fix to a race condition in rmid initialization. 
> Briefly, rmid subclasses the RMI registry implementation and provides 
> special handling for its own stub. Unfortunately the registry is 
> exported in the super() call, making remote calls possible before 
> rmid's stub initialization is complete. The fix is to ensure that all 
> remote calls wait for initialization before proceeding.
>
> Bug:
>
>     https://bugs.openjdk.java.net/browse/JDK-8023541
>
> Webrev:
>
>     http://cr.openjdk.java.net/~smarks/reviews/8023541/webrev.0/
>
> Thanks,
>
> s'marks




More information about the core-libs-dev mailing list