Skip to content

TransferPathLeg exposes the wrong toStop in reverse searches - #8062

Open
t2gran wants to merge 1 commit into
opentripplanner:dev-2.xfrom
entur:fix-reverse-transfer-leg-stop
Open

t2gran wants to merge 1 commit into
opentripplanner:dev-2.xfrom
entur:fix-reverse-transfer-leg-stop

Conversation

@t2gran

@t2gran t2gran commented Oct 1, 2026

Copy link
Copy Markdown
Member

Summary

TransferPathLeg derived its toStop from transfer.stop(), but that is direction-relative: a transfer obtained through
RaptorTransitDataProvider#getTransfersToStop(int) (the reverse-search path) reports stop() as the leg's origin, not its destination. The correct, direction-independent destination stop was already computed and threaded through PathBuilderLeg (every caller of PathBuilder#transfer(transfer, toStop) already passes it explicitly - see ForwardPathMapper and ReversePathMapper), but PathBuilderLeg#createTransferPathLeg() never used it, letting TransferPathLeg's constructor silently re-derive the wrong value from transfer.stop() instead.

TransferPathLeg now takes toStop as an explicit constructor parameter, and createTransferPathLeg() passes the already-correct PathBuilderLeg#toStop() through instead of leaving it to be recomputed. This is also one step closer to NOT hold a reference to the transfer in transfer arrivals - this is not needed and would save memory and speed up the search.

The existing basic-path forward/reverse-search test only asserts on the path's rendered string, which (misleadingly) does not depend on TransferPathLeg#toStop() and therefore didn't catch this. Added a direct assertion on the reverse-search transfer leg's fromStop()/toStop() to PathMapperTest, which fails with the expected <3> but was <2> before this fix and passes after it.

Issue

closes #8047

Unit tests

✅ Updated

Documentation

✅ JavaDoc added

Changelog

✅ Minor bugfix - not visible in the APIs

Bumping the serialization version id

🟥 No serialized data changed

@t2gran t2gran added this to the 2.11 (next release) milestone Oct 1, 2026
@t2gran
t2gran requested a review from a team as a code owner October 1, 2026 00:13
@t2gran t2gran added the !Bug Apply to issues describing a bug and PRs witch fixes it. label Oct 1, 2026
…ches

TransferPathLeg derived its toStop from transfer.stop(), but that is
direction-relative: a transfer obtained through
RaptorTransitDataProvider#getTransfersToStop(int) (the reverse-search path)
reports stop() as the leg's origin, not its destination. The correct,
direction-independent destination stop was already computed and threaded
through PathBuilderLeg (every caller of PathBuilder#transfer(transfer,
toStop) already passes it explicitly - see ForwardPathMapper and
ReversePathMapper), but PathBuilderLeg#createTransferPathLeg() never used
it, letting TransferPathLeg's constructor silently re-derive the wrong
value from transfer.stop() instead.

TransferPathLeg now takes toStop as an explicit constructor parameter, and
createTransferPathLeg() passes the already-correct PathBuilderLeg#toStop()
through instead of leaving it to be recomputed.

The existing basic-path forward/reverse-search test only asserts on the
path's rendered string, which (misleadingly) does not depend on
TransferPathLeg#toStop() and therefore didn't catch this. Added a direct
assertion on the reverse-search transfer leg's fromStop()/toStop() to
PathMapperTest, which fails with the expected <3> but was <2> before this
fix and passes after it.

closes opentripplanner#8047
@t2gran
t2gran force-pushed the fix-reverse-transfer-leg-stop branch from 5fa2c03 to e0dc038 Compare October 1, 2026 00:17
@codecov

codecov Bot commented Oct 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.62%. Comparing base (1110116) to head (e0dc038).

Additional details and impacted files
@@            Coverage Diff             @@
##             dev-2.x    #8062   +/-   ##
==========================================
  Coverage      74.61%   74.62%           
- Complexity     22875    22876    +1     
==========================================
  Files           2533     2533           
  Lines          88523    88523           
  Branches        8752     8752           
==========================================
+ Hits           66055    66058    +3     
+ Misses         19399    19396    -3     
  Partials        3069     3069           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

!Bug Apply to issues describing a bug and PRs witch fixes it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TransferPathLeg exposes the wrong toStop when used with SearchDirection.REVERSE

1 participant