You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using GeoJsonReader from jts-io-common 1.17.1 for reading (and validating) input string in geoJson format. (Previously I used version 1.16.0 but then tried the latest version).
It works correctly for most ‘bad inputs’ and a ParseException is thrown.
In one case (I am not able to find more at this time) the read method throws ClassCastException instead of ParseException: for input string "[]".
The problem is in this method:
org.locationtech.jts.io.geojson.GeoJsonReader#read(java.io.Reader)
JSONParser understands the "[]" string as a JSONArray, but JSONArray cannot be casted to java.util.Map.
I believe that the result of parser.parse(reader) should be checked for object type and fail (throw ParseException) if it is not JSONObject.
public Geometry read(Reader reader) throws ParseException {
Geometry result = null;
JSONParser parser = new JSONParser();
try {
Map<String, Object> geometryMap = (Map)parser.parse(reader);
GeometryFactory geometryFactory = null;
if (this.gf == null) {
geometryFactory = this.getGeometryFactory(geometryMap);
} else {
geometryFactory = this.gf;
}
result = this.create(geometryMap, geometryFactory);
return result;
} catch (org.json.simple.parser.ParseException var6) {
throw new ParseException(var6);
} catch (IOException var7) {
throw new ParseException(var7);
}
}
The text was updated successfully, but these errors were encountered:
I am using GeoJsonReader from jts-io-common 1.17.1 for reading (and validating) input string in geoJson format. (Previously I used version 1.16.0 but then tried the latest version).
It works correctly for most ‘bad inputs’ and a ParseException is thrown.
In one case (I am not able to find more at this time) the read method throws ClassCastException instead of ParseException: for input string "[]".
The problem is in this method:
org.locationtech.jts.io.geojson.GeoJsonReader#read(java.io.Reader)
and line
JSONParser understands the "[]" string as a JSONArray, but JSONArray cannot be casted to java.util.Map.
I believe that the result of
parser.parse(reader)
should be checked for object type and fail (throw ParseException) if it is not JSONObject.The text was updated successfully, but these errors were encountered: