AbstractNavitiaProvider: Fix NullPointerException.

4f7bd832e6 introduced a
NullPointerException in AbstractNavitiaProvider.
The call to Context() in line 970 calls prevQueryUrl.toString() and
nextQueryUrl.toString().
The variables are however null in the case that the search returned
only one result. The easiest way to reproduce this is searching
for two very near locations. The result will then be one walk-route.
This commit fixes the NPE by restoring the old behavior and has been
tested in Transportr.
This commit is contained in:
Patrick Kanzler 2017-01-18 01:27:49 +01:00 committed by Andreas Schildbach
parent 0f77095d65
commit a9e254c3ae

View file

@ -966,8 +966,11 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider {
} }
} }
String prevQueryUrlString = prevQueryUrl != null ? prevQueryUrl.toString() : null;
String nextQueryUrlString = nextQueryUrl != null ? nextQueryUrl.toString() : null;
final QueryTripsResult result = new QueryTripsResult(resultHeader, url.build().toString(), from, final QueryTripsResult result = new QueryTripsResult(resultHeader, url.build().toString(), from,
null, to, new Context(from, to, prevQueryUrl.toString(), nextQueryUrl.toString()), null, to, new Context(from, to, prevQueryUrlString, nextQueryUrlString),
new LinkedList<Trip>()); new LinkedList<Trip>());
parseQueryTripsResult(head, from, to, result); parseQueryTripsResult(head, from, to, result);