Repository navigation
Fix NPE when routing on a graph without transit data. - #3804
Conversation
"graph contains no agencies (yet); API request times will be interpreted as GMT." is already emitted, make it true (cherry picked from commit 795a42a8ca3f36ffdc9dbb5d7d6d73888c392dfa)
| public RoutingResponse route(RoutingRequest request, Router router) { | ||
| try { | ||
| var zoneId = graph.getTransitLayer().getTransitDataZoneId(); | ||
| var zoneId = graph.getTimeZone().toZoneId(); |
There was a problem hiding this comment.
Are we sure this do not create a new problem if these timezone differ? There should only be one truth/source.
There was a problem hiding this comment.
What do you suggest? Only change the code in case where getTransitLayer returns null? And copy the logic of handling null over for the other case?
| var zoneId = graph.getTimeZone().toZoneId(); | |
| var zoneId = graph.getTransitLayer() ? graph.getTransitLayer().getTransitDataZoneId() : TimeZone.getTimeZone("GMT"); |
There was a problem hiding this comment.
I think I will just approve your initial suggestion. I looked at the code now, and I see that we copy the TimeZone from the graph into the TransitLayer, so I think it is ok. This is probably something that I would like to take a second look at, while cleaning up the TransitLayer - and removing all transit data from the graph - we would like to break the OTP into smaller pieces. There should be a transit model, and the global OTP context should have a ref to it and inject it where needed.
|
Once more, if it's good enough for @t2gran then it's good enough for me. |
Summary
Allow routing without a transit graph. This patch fixes a null pointer exception when reading the time zone from the (non-existant) transit layer by using the existing helper function in the graph object.
Unit tests
I have tested the change by routing on a graph without transit data.
Code style
Have you followed the suggested code style?