mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-19 00:39:58 +00:00
Hafas: Handle unparsable XML when querying for departures.
This commit is contained in:
parent
1ae48117ba
commit
5048e826dc
1 changed files with 5 additions and 2 deletions
|
@ -505,11 +505,14 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
||||||
final String normalizedStationId = normalizeStationId(stationId);
|
final String normalizedStationId = normalizeStationId(stationId);
|
||||||
|
|
||||||
StringReplaceReader reader = null;
|
StringReplaceReader reader = null;
|
||||||
|
String firstChars = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// work around unparsable XML
|
// work around unparsable XML
|
||||||
reader = new StringReplaceReader(new InputStreamReader(httpClient.getInputStream(uri), Charsets.ISO_8859_1), " & ", " & ");
|
final InputStream is = httpClient.getInputStream(uri);
|
||||||
|
firstChars = HttpClient.peekFirstChars(is);
|
||||||
|
reader = new StringReplaceReader(new InputStreamReader(is, Charsets.ISO_8859_1), " & ", " & ");
|
||||||
reader.replace("<b>", " ");
|
reader.replace("<b>", " ");
|
||||||
reader.replace("</b>", " ");
|
reader.replace("</b>", " ");
|
||||||
reader.replace("<u>", " ");
|
reader.replace("<u>", " ");
|
||||||
|
@ -741,7 +744,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
||||||
}
|
}
|
||||||
catch (final XmlPullParserException x)
|
catch (final XmlPullParserException x)
|
||||||
{
|
{
|
||||||
throw new RuntimeException(x);
|
throw new ParserException("cannot parse xml: " + firstChars, x);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue