Skip to content

Commit

Permalink
check getCurrentFuelPercent null value and drop NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
JustCris654 committed Jan 9, 2025
1 parent ff8411a commit 6778169
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,16 @@ public VehicleRentalVehicle mapFreeVehicleStatus(GBFSBike vehicle) {
: null;
Ratio fuelPercent = null;
try {
fuelPercent = new Ratio(vehicle.getCurrentFuelPercent());
if (vehicle.getCurrentFuelPercent() != null) {
fuelPercent = new Ratio(vehicle.getCurrentFuelPercent());
}
} catch (IllegalArgumentException e) {
LOG.warn(
"Current fuel percent value not valid: {} - {}",
vehicle.getCurrentFuelPercent(),
e.getMessage()
);
} catch (NullPointerException e) {}
}
Distance rangeMeters = null;
try {
rangeMeters =
Expand Down

0 comments on commit 6778169

Please sign in to comment.