Skip to content

Commit

Permalink
Apply review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Aug 8, 2024
1 parent f2ba2c8 commit e4199f1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public class VehicleParking implements Serializable {
/**
* The currently available spaces at this vehicle parking.
*/
private VehicleParkingSpaces availability;
private volatile VehicleParkingSpaces availability;
/**
* The vehicle parking group this parking belongs to.
*/
Expand Down Expand Up @@ -254,9 +254,13 @@ public boolean hasRealTimeDataForMode(
/**
* The only mutable method in this class: it allows to update the available parking spaces during
* real-time updates.
* Since the entity is used both by writer threads (real-time updates) and reader threads
* (A* routing), the update process is synchronized.
*/
public void updateAvailability(VehicleParkingSpaces vehicleParkingSpaces) {
this.availability = vehicleParkingSpaces;
synchronized (this) {
this.availability = vehicleParkingSpaces;
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void run(Graph graph, TransitModel ignored) {

private void handleUpdate(AvailabiltyUpdate update) {
if (!parkingById.containsKey(update.vehicleParkingId())) {
LOG.error(
LOG.warn(
"Parking with id {} does not exist. Skipping availability update.",
update.vehicleParkingId()
);
Expand Down

0 comments on commit e4199f1

Please sign in to comment.