Bug 333383 - wrong "redundant null check" warning after synchronized
Summary: wrong "redundant null check" warning after synchronized
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.7 M5   Edit
Assignee: Ayushman Jain CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-02 06:34 EST by Jonathan Amir CLA
Modified: 2011-01-25 03:27 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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