4

Findbugs triggers NP_NULL_PARAM_DEREF_NONVIRTUAL in the below statement

I can't figure out why findbugs recognize registerationdate as nonnull parameter. I can see the second constructor checks nullness of registerationdate. Therefore, null deref is not probable.

Is this bug, false positive or findbugs has another mechanism to check the nonnull of a parameter?

Many thanks in advance, Zahra

Participant seppl = new Participant( "Mayer", "Seppel", null);

Participant has two constructors:
public Participant() {      
    surname = "";
    forename = "";      
    registrationDate = new Date();      
}

public Participant (String surname, String forename, Date registrationDate) {

    setSurname(surname);
    setForename(forename);      
    setRegistrationDate(registrationDate);      
 }

 public void setRegistrationDate (Date registrationDate) {
    if (registrationDate != null
            && !registrationDate.equals(this.registrationDate)) {
        this.registrationDate = registrationDate;           

    }
    }
user3610899
  • 121
  • 2
  • 7
  • It seems to me that FindBugs is not clever enough in this case to properly deal with the lazy evaluation of the boolean expression. You might want to try nested `if` statements. The outer statement would check that `registrationDate` is not `null`, and the inner statement performs the `equals()` check. – barfuin Jul 18 '14 at 08:00

1 Answers1

1

Thanks It was my fault... when I added "registrationDate != null" the bug disappered ..

user3610899
  • 121
  • 2
  • 7