opentripplanner / OpenTripPlanner

An open source multi-modal trip planner
http://www.opentripplanner.org
Other
2.18k stars 1.02k forks source link

Improve handling of SIRI added trip with unresolvable agency #5931

Closed vpaturet closed 2 months ago

vpaturet commented 3 months ago

Summary

When creating an extra-journey, the SIRI updater attempts to resolve the agency to which the trip belongs. The algorithm does not always succeed in finding the agency. When it fails, it leads to a NullPointerException:

Adding EstimatedJourney EstimatedVehicleJourney{EstimatedVehicleJourneyCode: 'TRO:ServiceJourney:26_240524122635892_1084:3510509093', Operator: TRO:Operator:960, Line: TRO:Line:1_26} failed.
java.lang.NullPointerException: null
    at java.base/java.util.Objects.requireNonNull(Objects.java:233)
    at org.opentripplanner.transit.model.network.Route.<init>(Route.java:46)
    at org.opentripplanner.transit.model.network.RouteBuilder.buildFromValues(RouteBuilder.java:215)
    at org.opentripplanner.transit.model.network.RouteBuilder.buildFromValues(RouteBuilder.java:14)
    at org.opentripplanner.transit.model.framework.AbstractBuilder.build(AbstractBuilder.java:33)
    at org.opentripplanner.ext.siri.AddedTripBuilder.createRoute(AddedTripBuilder.java:308)
    at org.opentripplanner.ext.siri.AddedTripBuilder.build(AddedTripBuilder.java:175)
    at org.opentripplanner.ext.siri.SiriTimetableSnapshotSource.apply(SiriTimetableSnapshotSource.java:154)
    at org.opentripplanner.ext.siri.SiriTimetableSnapshotSource.lambda$applyEstimatedTimetable$1(SiriTimetableSnapshotSource.java:118)
    at org.opentripplanner.updater.trip.TimetableSnapshotManager.withLock(TimetableSnapshotManager.java:218)
    at org.opentripplanner.ext.siri.SiriTimetableSnapshotSource.applyEstimatedTimetable(SiriTimetableSnapshotSource.java:107)
    at org.opentripplanner.ext.siri.updater.EstimatedTimetableHandler.applyUpdate(EstimatedTimetableHandler.java:61)
    at org.opentripplanner.ext.siri.updater.AsyncEstimatedTimetableProcessor.lambda$processSiriData$0(AsyncEstimatedTimetableProcessor.java:38)
    at org.opentripplanner.updater.GraphUpdaterManager.lambda$execute$1(GraphUpdaterManager.java:192)

This PR handles this corner case by reporting a specific error message in this case. (This will allow further analysis by reviewing error log messages)

Issue

No

Unit tests

Added unit test

Documentation

No

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 69.45%. Comparing base (ce93c85) to head (d0ec77e). Report is 2 commits behind head on dev-2.x.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## dev-2.x #5931 +/- ## ========================================== Coverage 69.45% 69.45% - Complexity 17065 17072 +7 ========================================== Files 1934 1934 Lines 73624 73628 +4 Branches 7539 7540 +1 ========================================== + Hits 51134 51140 +6 + Misses 19866 19864 -2 Partials 2624 2624 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

vpaturet commented 3 months ago

@lassetyr we apply today some complex logic to "guess" the agency of an extra journey when its line or replaced line cannot be resolved. Should extra journeys that do not refer to an existing line or existing replaced line simply be discarded? What are the requirements in the Nordic SIRI profile?