Skip to content

Commit 9ceb2c0

Browse files
committed
Clear patternsForStop in clear method of TimetableSnapshot.
1 parent 2d099fa commit 9ceb2c0

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

application/src/main/java/org/opentripplanner/transit/model/timetable/TimetableSnapshot.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,11 +428,13 @@ public void clear(String feedId) {
428428
feedId
429429
);
430430
boolean addedTripPatternsWereCleared = clearEntriesForRealtimeAddedTrips(feedId);
431+
boolean patternsForStopWereCleared = clearPatternsForStop(feedId);
431432
// If this snapshot was modified, it will be dirty after the clear actions.
432433
if (
433434
timetablesWereCleared ||
434435
newTripPatternsForModifiedTripsWereCleared ||
435-
addedTripPatternsWereCleared
436+
addedTripPatternsWereCleared ||
437+
patternsForStopWereCleared
436438
) {
437439
dirty = true;
438440
}
@@ -615,7 +617,9 @@ private boolean clearNewTripPatternsForModifiedTrips(String feedId) {
615617
/**
616618
* Clear all realtime added routes, trip patterns and trips matching the provided feed id.
617619
*
618-
* */
620+
* @param feedId feed id to clear out
621+
* @return true if realTimeAddedTrips changed as a result of the call
622+
*/
619623
private boolean clearEntriesForRealtimeAddedTrips(String feedId) {
620624
// it is sufficient to test for the removal of added trips, since other indexed entities are
621625
// added only if a new trip is added.
@@ -634,6 +638,16 @@ private boolean clearEntriesForRealtimeAddedTrips(String feedId) {
634638
return removedEntry;
635639
}
636640

641+
/**
642+
* Clear all trip patterns from patternsForStop matching the provided feed id.
643+
*
644+
* @param feedId feed id to clear out
645+
* @return true if patternsForStop changed as a result of the call
646+
*/
647+
private boolean clearPatternsForStop(String feedId) {
648+
return patternsForStop.entries().removeIf(entry -> entry.getValue().getFeedId().equals(feedId));
649+
}
650+
637651
/**
638652
* Add the patterns to the stop index, only if they come from a real-time pattern.
639653
*/

0 commit comments

Comments
 (0)