From d2fe93b16a6961687cbee0c1a77d2786c27d430d Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Tue, 30 Oct 2018 10:16:48 +0100 Subject: [PATCH] AbstractHafasClientInterfaceProvider: Handle missing 'stopL' when querying trips. --- .../AbstractHafasClientInterfaceProvider.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/enabler/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java b/enabler/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java index 7781629d..d95d3f68 100644 --- a/enabler/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java @@ -536,13 +536,18 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas final Location destination = dirTxt != null ? new Location(LocationType.ANY, null, null, dirTxt) : null; - final JSONArray stopList = jny.getJSONArray("stopL"); - checkState(stopList.length() >= 2); - final List intermediateStops = new ArrayList<>(stopList.length()); - for (int iStop = 1; iStop < stopList.length() - 1; iStop++) { - final JSONObject stop = stopList.getJSONObject(iStop); - final Stop intermediateStop = parseJsonStop(stop, locList, c, baseDate); - intermediateStops.add(intermediateStop); + final JSONArray stopList = jny.optJSONArray("stopL"); + final List intermediateStops; + if (stopList != null) { + checkState(stopList.length() >= 2); + intermediateStops = new ArrayList<>(stopList.length()); + for (int iStop = 1; iStop < stopList.length() - 1; iStop++) { + final JSONObject stop = stopList.getJSONObject(iStop); + final Stop intermediateStop = parseJsonStop(stop, locList, c, baseDate); + intermediateStops.add(intermediateStop); + } + } else { + intermediateStops = null; } final JSONArray remList = jny.optJSONArray("remL");