streampipes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zehn...@apache.org
Subject [incubator-streampipes] branch dev updated: Add debugging info to json parser in case of invalid json
Date Sat, 07 Dec 2019 23:03:21 GMT
This is an automated email from the ASF dual-hosted git repository.

zehnder pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git


The following commit(s) were added to refs/heads/dev by this push:
     new 750126a  Add debugging info to json parser in case of invalid json
750126a is described below

commit 750126a85614dcea1714442be08b5aa00a68f33e
Author: Philipp Zehnder <zehnder@fzi.de>
AuthorDate: Sat Dec 7 23:51:48 2019 +0100

    Add debugging info to json parser in case of invalid json
---
 .../connect/adapter/format/json/object/JsonObjectParser.java   | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/streampipes-connect/src/main/java/org/streampipes/connect/adapter/format/json/object/JsonObjectParser.java
b/streampipes-connect/src/main/java/org/streampipes/connect/adapter/format/json/object/JsonObjectParser.java
index 70cddd9..04b8fb9 100644
--- a/streampipes-connect/src/main/java/org/streampipes/connect/adapter/format/json/object/JsonObjectParser.java
+++ b/streampipes-connect/src/main/java/org/streampipes/connect/adapter/format/json/object/JsonObjectParser.java
@@ -18,6 +18,7 @@
 package org.streampipes.connect.adapter.format.json.object;
 
 
+import org.apache.commons.io.IOUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.streampipes.commons.exceptions.SpRuntimeException;
@@ -33,7 +34,9 @@ import org.streampipes.model.schema.EventSchema;
 import javax.json.Json;
 import javax.json.stream.JsonParserFactory;
 import javax.json.stream.JsonParsingException;
+import java.io.IOException;
 import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -87,8 +90,13 @@ public class JsonObjectParser extends Parser {
             }
 
         } catch(JsonParsingException e) {
-          //  logger.error("Error. Currently just one Object is supported in JSONObjectParser");
             logger.error("Could not parse Data to JSONObject");
+            try {
+                String event = IOUtils.toString(data, StandardCharsets.UTF_8.name());
+                logger.error("Event no valid json: " + event);
+            } catch (IOException e1) {
+                e1.printStackTrace();
+            }
             throw new ParseException("Could not parse Data to JSONObject.");
         }
 


Mime
View raw message