I get a NullPointerException while running my webapplication, I save a logs and start server again and this error no longer there appeared, but i want protect method to NullPointer never appeared. I sure this line is responsible for this error
Vehicle pVehicle =
Iterables.tryFind(aFactory.getVehicle(), new Predicate<Vehicle>() {
@Override
public boolean apply(Vehicle vehicle) {
return vehicle.getVehicleBrand().equals(aVehicle.getVehicleBrand());
}
}).orNull();
But this is not my code, and i don't known, which part may cause this error> Please, which element can be appeared for this NullPointer and how protect this code
Check the following statements:
aFactory
- Because of the getVehicle()
call.aFactory.getVehicle()
- Because Iterables.tryFind expects a non-null Iterablevehicle
- Because of the getVehicleBrand()
callaVehicle
- Because of the getVehicleBrand()
callvehicle.getVehicleBrand()
- Because of the .equals()
callIf any of these were null it would cause an NullPointerException