Modify

Opened 2 years ago

Closed 23 months ago

Last modified 23 months ago

#22680 closed defect (fixed)

[PATCH] Unexpected exception downloading from Overpass query

Reported by: watmildon Owned by: team
Priority: normal Milestone: 23.02
Component: Core Version:
Keywords: template_report Cc:

Description (last modified by taylor.smock)

What steps will reproduce the problem?

  1. Have some data in a layer (attached osm file)
  2. I was downloading this query with a bounding box of 23.8858377;-129.375;52.4827802;-62.2265625
    [out:json][timeout:25];
    // gather results
    (
      // query for all cases where the various synonyms for gnis id's match
      nwr["tiger:PLACENS"];
    );
    // print results
    out body;
    >;
    

What is the expected result?

Data downloads and is rendered

What happens instead?

Apparently this exception!

Please provide any additional information below. Attach a screenshot if possible.

Revision:18622
Build-Date:2023-01-04 12:54:08

Identification: JOSM/1.5 (18622 en) Windows 10 64-Bit
OS Build number: Windows 10 Pro 2009 (19045)
Memory Usage: 3816 MB / 4088 MB (2223 MB allocated, but free)
Java version: 17.0.5+8-LTS, Azul Systems, Inc., OpenJDK 64-Bit Server VM
Look and Feel: com.sun.java.swing.plaf.windows.WindowsLookAndFeel
Screen: \Display0 1440×2560 (scaling 1.00×1.00) \Display1 3840×2160 (scaling 1.50×1.50)
Maximum Screen Size: 3840×2560
Best cursor sizes: 16×16→48×48, 32×32→48×48
System property file.encoding: Cp1252
System property sun.jnu.encoding: Cp1252
Locale info: en_US
Numbers with default locale: 1234567890 -> 1234567890
VM arguments: [-Djpackage.app-version=1.5.18622, --add-modules=java.scripting,java.sql,javafx.controls,javafx.media,javafx.swing,javafx.web, --add-exports=java.base/sun.security.action=ALL-UNNAMED, --add-exports=java.desktop/com.sun.imageio.plugins.jpeg=ALL-UNNAMED, --add-exports=java.desktop/com.sun.imageio.spi=ALL-UNNAMED, --add-opens=java.base/java.lang=ALL-UNNAMED, --add-opens=java.base/java.nio=ALL-UNNAMED, --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED, --add-opens=java.base/jdk.internal.ref=ALL-UNNAMED, --add-opens=java.desktop/javax.imageio.spi=ALL-UNNAMED, --add-opens=java.desktop/javax.swing.text.html=ALL-UNNAMED, --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED, -Djpackage.app-path=%UserProfile%\AppData\Local\JOSM\JOSM.exe]
Dataset consistency test: No problems found

Plugins:
+ FastDraw (35978)
+ FixAddresses (36011)
+ apache-commons (36034)
+ apache-http (35924)
+ buildings_tools (36011)
+ conflation (0.6.9)
+ continuosDownload (105)
+ contourmerge (v0.1.9)
+ ejml (35924)
+ geotools (36028)
+ gridify (1606242219)
+ imagery_offset_db (35978)
+ jackson (36034)
+ jaxb (35952)
+ jna (36005)
+ jts (36004)
+ mapwithai (v1.10.3)
+ opendata (36025)
+ tageditor (36011)
+ terracer (35978)
+ todo (30306)
+ turnrestrictions (36011)
+ utilsplugin2 (36011)
+ wikipedia (605)

Map paint styles:
+ https://josm.openstreetmap.de/josmfile?page=Styles/TigerReviewedNo&zip=1
- %UserProfile%\Address Tags Validator - Highlight unaddressed
- https://josm.openstreetmap.de/josmfile?page=Styles/Modified&zip=1
+ https://josm.openstreetmap.de/josmfile?page=Styles/AddressValidator&zip=1
+ https://josm.openstreetmap.de/josmfile?page=Styles/MapWithAI&zip=1
- https://josm.openstreetmap.de/josmfile?page=Styles/Coloured_Streets&zip=1

Last errors/warnings:
- 126865.716 E: org.openstreetmap.josm.io.OsmApiException: ResponseCode=500, Error Body=<<!DOCTYPE html>
- 126865.723 E: Internal Server Error - <html>The OSM server<br>'https://api.openstreetmap.org/api/0.6/'<br>reported an internal server error.<br>This is most likely a temporary problem. Please try again later.</html>
- 159429.493 E: org.openstreetmap.josm.io.OsmApiException: ResponseCode=400, Error Header=<line 5: parse error: ) expected - ; found.>, Error Body=<<?xml version="1.0" encoding="UTF-8"?>
- 159429.501 E: Bad Request - <html>The OSM server 'overpass-api.de' reported a bad request.<br><br>Error message(untranslated): line 5: parse error: ) expected - ; found. </html>
- 159463.004 E: org.openstreetmap.josm.io.OsmApiException: ResponseCode=400, Error Header=<line 5: parse error: ) expected - ; found.>, Error Body=<<?xml version="1.0" encoding="UTF-8"?>
- 159463.010 E: Bad Request - <html>The OSM server 'overpass-api.de' reported a bad request.<br><br>Error message(untranslated): line 5: parse error: ) expected - ; found. </html>
- 191671.327 W: java.net.SocketException: Socket closed. Cause: java.net.SocketException: Socket closed
- 191671.328 E: java.net.SocketException: Socket closed. Cause: java.net.SocketException: Socket closed
- 196955.672 E: Handled by bug report queue: javax.json.JsonException: I/O error while parsing JSON. Cause: java.net.SocketTimeoutException: Read timed out
- 202395.093 E: Handled by bug report queue: javax.json.JsonException: I/O error while parsing JSON. Cause: java.net.SocketTimeoutException: Read timed out



=== REPORTED CRASH DATA ===
BugReportExceptionHandler#handleException:
No data collected.

Warning issued by: BugReportExceptionHandler#handleException

=== STACK TRACE ===
Thread: AWT-EventQueue-0 (23) of main
javax.json.JsonException: I/O error while parsing JSON
	at org.glassfish.json.JsonTokenizer.peek(JsonTokenizer.java:461)
	at org.glassfish.json.JsonTokenizer.hasNextToken(JsonTokenizer.java:443)
	at org.glassfish.json.JsonParserImpl.hasNext(JsonParserImpl.java:364)
	at org.glassfish.json.JsonParserImpl.getObject(JsonParserImpl.java:334)
	at org.glassfish.json.JsonParserImpl.getValue(JsonParserImpl.java:182)
	at org.glassfish.json.JsonParserImpl.getArray(JsonParserImpl.java:328)
	at org.glassfish.json.JsonParserImpl.getValue(JsonParserImpl.java:180)
	at org.glassfish.json.JsonParserImpl.getObject(JsonParserImpl.java:341)
	at org.glassfish.json.JsonParserImpl.getValue(JsonParserImpl.java:182)
	at org.glassfish.json.JsonParserImpl.getArray(JsonParserImpl.java:328)
	at org.glassfish.json.JsonParserImpl.getValue(JsonParserImpl.java:180)
	at org.glassfish.json.JsonParserImpl.getObject(JsonParserImpl.java:341)
	at org.glassfish.json.JsonParserImpl.getObject(JsonParserImpl.java:173)
	at org.openstreetmap.josm.io.OsmJsonReader.parse(OsmJsonReader.java:57)
	at org.openstreetmap.josm.io.OsmJsonReader.lambda$doParseDataSet$6(OsmJsonReader.java:183)
	at org.openstreetmap.josm.io.AbstractReader.doParseDataSet(AbstractReader.java:300)
	at org.openstreetmap.josm.io.OsmJsonReader.doParseDataSet(OsmJsonReader.java:181)
	at org.openstreetmap.josm.io.OverpassDownloadReader.parseDataSet(OverpassDownloadReader.java:394)
	at org.openstreetmap.josm.io.BoundingBoxDownloader.parseOsm(BoundingBoxDownloader.java:215)
	at org.openstreetmap.josm.io.OverpassDownloadReader.parseOsm(OverpassDownloadReader.java:400)
	at org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask$DownloadTask.parseDataSet(DownloadOsmTask.java:469)
	at org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask$DownloadTask.realRun(DownloadOsmTask.java:477)
	at org.openstreetmap.josm.gui.PleaseWaitRunnable.doRealRun(PleaseWaitRunnable.java:94)
	at org.openstreetmap.josm.gui.PleaseWaitRunnable.run(PleaseWaitRunnable.java:142)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.net.SocketTimeoutException: Read timed out
	at java.base/sun.nio.ch.NioSocketImpl.timedRead(Unknown Source)
	at java.base/sun.nio.ch.NioSocketImpl.implRead(Unknown Source)
	at java.base/sun.nio.ch.NioSocketImpl.read(Unknown Source)
	at java.base/sun.nio.ch.NioSocketImpl$1.read(Unknown Source)
	at java.base/java.net.Socket$SocketInputStream.read(Unknown Source)
	at java.base/sun.security.ssl.SSLSocketInputRecord.read(Unknown Source)
	at java.base/sun.security.ssl.SSLSocketInputRecord.readHeader(Unknown Source)
	at java.base/sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket(Unknown Source)
	at java.base/sun.security.ssl.SSLSocketImpl.readApplicationRecord(Unknown Source)
	at java.base/sun.security.ssl.SSLSocketImpl$AppInputStream.read(Unknown Source)
	at java.base/java.io.BufferedInputStream.fill(Unknown Source)
	at java.base/java.io.BufferedInputStream.read1(Unknown Source)
	at java.base/java.io.BufferedInputStream.read(Unknown Source)
	at java.base/sun.net.www.http.ChunkedInputStream.readAheadBlocking(Unknown Source)
	at java.base/sun.net.www.http.ChunkedInputStream.readAhead(Unknown Source)
	at java.base/sun.net.www.http.ChunkedInputStream.read(Unknown Source)
	at java.base/java.io.FilterInputStream.read(Unknown Source)
	at java.base/sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(Unknown Source)
	at org.openstreetmap.josm.io.ProgressInputStream.read(ProgressInputStream.java:49)
	at java.base/java.util.zip.InflaterInputStream.fill(Unknown Source)
	at java.base/java.util.zip.InflaterInputStream.read(Unknown Source)
	at java.base/java.util.zip.GZIPInputStream.read(Unknown Source)
	at java.base/java.io.FilterInputStream.read(Unknown Source)
	at java.base/java.io.PushbackInputStream.read(Unknown Source)
	at java.base/sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
	at java.base/sun.nio.cs.StreamDecoder.implRead(Unknown Source)
	at java.base/sun.nio.cs.StreamDecoder.read(Unknown Source)
	at java.base/java.io.InputStreamReader.read(Unknown Source)
	at org.glassfish.json.JsonTokenizer.fillBuf(JsonTokenizer.java:519)
	at org.glassfish.json.JsonTokenizer.peek(JsonTokenizer.java:451)
	... 28 more

Attachments (2)

unexpectedException.zip (3.8 MB ) - added by watmildon 2 years ago.
data layer from OSM already in JOSM
22680.patch (6.9 KB ) - added by taylor.smock 2 years ago.

Change History (10)

by watmildon, 2 years ago

Attachment: unexpectedException.zip added

data layer from OSM already in JOSM

comment:1 by taylor.smock, 2 years ago

Description: modified (diff)

comment:2 by taylor.smock, 2 years ago

javax.json.JsonException: I/O error while parsing JSON
[...snip...]
Caused by: java.net.SocketTimeoutException: Read timed out

It looks like this was either due to a network issue, or the server didn't respond in time. Probably the latter, but if you have flaky internet, it could have been the former.

Anyway, it looks like we started to read the JSON, then something came along and interrupted the stream from the server, which caused a JsonException, which, since it is a runtime exception, caused us to show the bug report window.

In order to fix this, we'd probably want to do something like

  • src/org/openstreetmap/josm/io/OsmJsonReader.java

    diff --git a/src/org/openstreetmap/josm/io/OsmJsonReader.java b/src/org/openstreetmap/josm/io/OsmJsonReader.java
    a b  
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.io.IOException;
    67import java.io.InputStream;
    78import java.util.Collection;
    89import java.util.Map.Entry;
    910
    1011import javax.json.Json;
    1112import javax.json.JsonArray;
     13import javax.json.JsonException;
    1214import javax.json.JsonNumber;
    1315import javax.json.JsonObject;
    1416import javax.json.JsonString;
     
    178180
    179181    @Override
    180182    protected DataSet doParseDataSet(InputStream source, ProgressMonitor progressMonitor) throws IllegalDataException {
    181         return doParseDataSet(source, progressMonitor, ir -> {
    182             setParser(Json.createParser(ir));
    183             parse();
    184         });
     183        try {
     184            return doParseDataSet(source, progressMonitor, ir -> {
     185                setParser(Json.createParser(ir));
     186                parse();
     187            });
     188        } catch (JsonException exception) {
     189            if (exception.getCause() instanceof IOException) {
     190                IllegalDataException ide = new IllegalDataException(exception.getCause());
     191                ide.addSuppressed(exception);
     192                throw ide;
     193            } else {
     194                throw exception;
     195            }
     196        }
    185197    }
    186198
    187199    /**

I'd prefer to throw the SocketException, since that will give a better description of what happened, but I don't have a good place to put the catch, as I am limited by the IllegalDataException constraint. I could change the signature of the method so that it can throw an IOException, but I don't know how many plugins that would affect.

If we do go with something like what I wrote, we might just wrap the entire JsonException in an IllegalDataException. Not great, since our current utils for explaining exceptions will probably just tell the user that there was a json exception, not that there was a socket exception. So the catch block would just look like throw new IllegalDataException(exception).

by taylor.smock, 2 years ago

Attachment: 22680.patch added

comment:3 by taylor.smock, 2 years ago

Milestone: 23.02
Summary: Unexpected exception downloading from Overpass query[PATCH] Unexpected exception downloading from Overpass query

comment:4 by watmildon, 2 years ago

I leave it to your infinite wisdom. It was completely reproducible last night (3 times) and I can't get it to repro this morning. Thanks for taking a look!

in reply to:  4 comment:5 by taylor.smock, 2 years ago

Replying to watmildon:

It was completely reproducible last night (3 times) and I can't get it to repro this morning.

That isn't surprising. Either it was a connection issue for you, or other people didn't file a bug report. In any case, I was able to reproduce it in tests by have a stream that returned a character, and then errored out.

TBH, I was kind of surprised to see that JsonException was a runtime exception. I would have expected it to be a checked exception.

Thanks for taking a look!

No problem. Thanks for reporting the ticket. I didn't see any duplicates for this either, which is surprising. I would have expected it or something like it to have been reported at least once.

comment:6 by watmildon, 2 years ago

I was doing a lot of work against the public overpass last night.. maybe it was cutting me off and this is how it gets bubbled up? hmmm.

comment:7 by taylor.smock, 23 months ago

Resolution: fixed
Status: newclosed

In 18656/josm:

Fix #22680: Unexpected exception when downloading GeoJSON

This occurs when we start to read the JSON, then something comes along and
interrupts the stream from the server. This then causes a JsonException
(a RuntimeException) to be thrown.

This patch catches the JsonException and then either rethrows it if the
cause was not an IOException or throws a new IllegalDataException with
the IOException as the cause and the JsonException as a suppressed exception.

comment:8 by taylor.smock, 23 months ago

In 18658/josm:

See #22680: Unexpected exception when downloading GeoJSON

This primarily adds a non-regression test, but also narrows the IOException
to SocketException to better match the exception type and adds a specific
catch for parsing issues.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.