There is a thing in java called autoboxing when primitive values ββare wrapped with object types and vice versa.
So there is a method in your code:
public Boolean isActive() { return active; }
note that you are returning a Boolean (object type), not a Boolean (primitive type).
and the return value will be used in your if statement.
if (data != null && data.isActive()) {
when java encounters data.isActive() in your if , it tries to convert the Boolean value to a primitive boolean to apply it to your boolean operation.
But your active variable inside your isActive() method is null, so java cannot remove this variable until the Boolean primitive value, and you get a Null pointer exception .
user784540
source share