In java, there's a thing called autoboxing, when primitive values are wrapped by object types and vice versa.
So, in your code there is a method:
public Boolean isActive()
{
return active;
}
note, that you are returning Boolean
(object type), not boolean
(primitive type).
and return value is going to be used in your if statement.
if (data != null && data.isActive()) {
when java meets data.isActive()
in your if
statement, it tries to convert Boolean value to primitive boolean value, to apply it for your logical operation.
But your active
variable inside of your isActive()
method is null, so java is unable to unbox this variable to boolean
primitive value, and you get Null pointer exception
.