package sfBugs;

import edu.umd.cs.findbugs.annotations.DesireNoWarning;

public class Bug3553542 {
    
    @DesireNoWarning( "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE")
    public static void checkIfNullIsReturned(GoodBehavingClass goodBehavingClass) {
        String isNullReturned;

        isNullReturned = goodBehavingClass.isNullReturned();

        if (isNullReturned != null) {
            System.out.println("No it isn't. It has length " + isNullReturned.length());
        } else {
            System.out.println("Yes it is.");
        }
    }

    static class GoodBehavingClass {
        public String isNullReturned() {
            return "noop";
        }
    }

    // Assume this is class is defined in some the third party implementation
    // using this FalsePositive as library code.
    static class BadBehavingClass /* extends GoodBehavingClass */ {
        
        public String isNullReturned() {
            return null;
        }
    }

    public static void main(String[] args) {
        checkIfNullIsReturned(new GoodBehavingClass());
        // Assume this is called in the third party implementation using this
        // FalsePositive as library code.
//        checkIfNullIsReturned(new BadBehavingClass());
    }
}

@@ -65,16 +65,66 @@
 Warning;
+%0Aimport edu.umd.cs.findbugs.annotations.NoWarning;
 %0A%0Apublic
@@ -1292,10 +1292,458 @@
 ;%0A    %7D%0A
+    %0A    %0A    Object globalError;%0A%0A    Object getGlobalError() %7B%0A        return globalError;%0A    %7D%0A    void myMethod() %7B%0A      // some code%0A%0A      if (Math.random() %3E 0.5)%0A          globalError = %22x%22;%0A      %0A%0A      // some code%0A    %7D%0A%0A    @NoWarning(%22RCN%22)%0A    void myProg() %7B%0A      globalError = null;%0A      myMethod();%0A%0A      // FindBugs considers this check resundant%0A      if (globalError != null) %7B%0A        // do something%0A%0A      %7D%0A    %7D%0A    %0A
 %7D%0A

Add additional test code