Title: BUG: Code Inspection: Singleton not recognized

21:  public static Singleton getInstance() {
22:    // Check instance existing
23:    if (instance == null) {
24:      // Lock any others (we can't put this before previos if, becose it make week place in code (method invoke for get object - too many invokations hapend))

25:      // We must to be sure that only one instance (only one thread) make instance creation
26:      synchronized (synchronizer) {
27:        // Check that instance isn't already created (theoretically its may happened, fisical - maybe no, but...)
28:        if (instance == null) {
29:          instance = new FileCache();
30:        }
31:      }
32:    }
33:    return instance;
34:  }

So, we see to "if conditions": And this reasonable to Code Analiser to say:
Problem synopsis:
Condition instance == null at line 28 is always true.

But this not right.

Thanks.

PS. The Code Inspection is great idea in IDEA :) Thank you for this gem! :)

Alexey Efimov - Software Engineer
Sputnik Labs
1st Kolobovsky per., 6/3
Moscow, 103051, Russia
Phone: +7 (095) 725 5444
Direct: +7 (501) 401 3217
Fax: +7 (095) 725 5443
E-Mail: mailto:[EMAIL PROTECTED]
http://www.spklabs.com

Reply via email to