opentripplanner / OpenTripPlanner

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

Fix NullPointerException in stop transfer priority cost vector generation #5943

Closed t2gran closed 2 days ago

t2gran commented 3 days ago

Summary

In some cases (transit period filtering) stops can be dropped after they are created. This causes the stop-index(used in routing) to contain holes in it. This happens because the stop index is assigned to a stop when it is created. In this PR, I have gone over the code to make sure holes in the stop-index is handled correctly and no NPE is thrown.

Issue

After enabling stopBoardAlightDuringTransferCost I got NPE locally during testing of OTP. This fixes the NPE in TransitLayerMapper and cleans up the code a bit.

Unit tests

🟥 I have not added any unit-tests for this. Instead I chose to improve logging and annotated with @Nullable in the appropriate place.

Documentation

🟥 I have just updated the JaveDoc - if relevant.

Changelog

✅ This is a minor bug fix.

Bumping the serialization version id

✅ The order of the StopTransferPriority enums are changed. This may have an effect on the serialization.

codecov[bot] commented 3 days ago

Codecov Report

Attention: Patch coverage is 80.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 69.45%. Comparing base (23f04a0) to head (0c914c4). Report is 7 commits behind head on dev-2.x.

Files Patch % Lines
...raptoradapter/transit/mappers/TransfersMapper.java 0.00% 1 Missing and 1 partial :warning:
...toradapter/transit/mappers/TransitLayerMapper.java 75.00% 1 Missing and 1 partial :warning:
...entripplanner/transit/model/site/StopLocation.java 0.00% 1 Missing :warning:
...pentripplanner/transit/service/StopModelIndex.java 88.88% 0 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## dev-2.x #5943 +/- ## ============================================= - Coverage 69.45% 69.45% -0.01% - Complexity 17070 17071 +1 ============================================= Files 1937 1937 Lines 73692 73710 +18 Branches 7540 7544 +4 ============================================= + Hits 51184 51192 +8 - Misses 19880 19885 +5 - Partials 2628 2633 +5 ```

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