You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2015/10/03 19:11:57 UTC
[3/5] jena git commit: JENA-1038: Convert Jackson JSON parsing
exceptions to RiotException.
JENA-1038: Convert Jackson JSON parsing exceptions to RiotException.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/d2144592
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/d2144592
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/d2144592
Branch: refs/heads/master
Commit: d21445922b371f9a56cb20df72cd3dae50db0306
Parents: 4dbae03
Author: Andy Seaborne <an...@apache.org>
Authored: Sat Oct 3 11:28:18 2015 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Sat Oct 3 11:28:18 2015 +0100
----------------------------------------------------------------------
.../org/apache/jena/riot/lang/JsonLDReader.java | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/d2144592/jena-arq/src/main/java/org/apache/jena/riot/lang/JsonLDReader.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/lang/JsonLDReader.java b/jena-arq/src/main/java/org/apache/jena/riot/lang/JsonLDReader.java
index 367e7fd..cca0f77 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/lang/JsonLDReader.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/lang/JsonLDReader.java
@@ -25,6 +25,9 @@ import java.util.List ;
import java.util.Map ;
import java.util.Map.Entry;
import java.util.Objects;
+
+import com.fasterxml.jackson.core.JsonLocation ;
+import com.fasterxml.jackson.core.JsonProcessingException ;
import com.github.jsonldjava.core.* ;
import com.github.jsonldjava.utils.JsonUtils ;
@@ -60,6 +63,13 @@ public class JsonLDReader implements ReaderRIOT
Object jsonObject = JsonUtils.fromReader(reader) ;
read$(jsonObject, baseURI, ct, output, context) ;
}
+ catch (JsonProcessingException ex) {
+ // includes JsonParseException
+ // The Jackson JSON parser, or addition JSON-level check, throws up something.
+ JsonLocation loc = ex.getLocation() ;
+ errorHandler.error(ex.getOriginalMessage(), loc.getLineNr(), loc.getColumnNr());
+ throw new RiotException(ex.getOriginalMessage()) ;
+ }
catch (IOException e) {
IO.exception(e) ;
}
@@ -71,18 +81,26 @@ public class JsonLDReader implements ReaderRIOT
Object jsonObject = JsonUtils.fromInputStream(in) ;
read$(jsonObject, baseURI, ct, output, context) ;
}
+ catch (JsonProcessingException ex) {
+ // includes JsonParseException
+ // The Jackson JSON parser, or addition JSON-level check, throws up something.
+ JsonLocation loc = ex.getLocation() ;
+ errorHandler.error(ex.getOriginalMessage(), loc.getLineNr(), loc.getColumnNr());
+ throw new RiotException(ex.getOriginalMessage()) ;
+ }
catch (IOException e) {
IO.exception(e) ;
}
}
- // This addresses jsonld-java issue #144 pre jsonld-java relase 0.6.0 in
+ // This addresses jsonld-java issue #144 prior to jsonld-java release 0.6.0 in
// Jena code so that we get triples/quads out then there is a parse error.
// Even if it is fixed in jsonld-java, it would mean that no triples would
// be produced - all the JSON parsing is done before JSON-LD processing.
// Here we process the first JSON object, which causes triples to be
// generated then decide whether to throw a parse error. This is more in the
// style of other syntaxes and stream parsing.
+ // This fix is in jsonld-java itself release 0.6.0 and later.
// @Override
// public void read(Reader reader, String baseURI, ContentType ct, StreamRDF output, Context context) {