Bug 333383

Summary: wrong "redundant null check" warning after synchronized
Product: [Eclipse Project] JDT Reporter: Jonathan Amir <jonathan_amir>
Component: CoreAssignee: Ayushman Jain <amj87.iitr>
Status: VERIFIED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: Olivier_Thomann, srikanth_sankaran
Version: 3.7   
Target Milestone: 3.7 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Jonathan Amir CLA 2011-01-02 06:34:22 EST
Build Identifier: 20100218-1602

Eclipse issues a warning about a redundant null check for the following code, at line 5:

public static X getX (String name) {
  X x = map.get(name);
  if (x == null) {
    synchronized (x) {
      if (x == null) { // wrong warning
        x = new X();
        map.put(name, x);
      }
    }
  }
  return x;
}


Reproducible: Always
Comment 1 Jonathan Amir CLA 2011-01-02 13:21:46 EST
My apologies, I had a mistake in the code sample.
Comment 2 Srikanth Sankaran CLA 2011-01-25 03:27:05 EST
Verified for 3.7 M5 using build id: I20110124-1800