When scanning the following code with findbugs, it tells Dodgy code: NP: Load the known null value into new .... (in the line where the new exception is thrown)
Sometimes, before initializing an object, you need to check the null value. Why is it considered "dodgy"?
public class Employee{
@Valid
private Department dept;
@JsonCreator
public Employee(@JsonProperty(value = "department", required = true) Department aDepartment)
throws EmpServiceException{
if (aDepartment == null) {
throw new EmpServiceException(aDepartment, "Invalid Request");
}
this.dept= aDepartment;
}
source
share