metron-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmerri...@apache.org
Subject [33/50] [abbrv] metron git commit: METRON-1521: JSONMapParser is no longer serializable closes apache/incubator-metron#991
Date Fri, 27 Apr 2018 19:30:13 GMT
METRON-1521: JSONMapParser is no longer serializable closes apache/incubator-metron#991


Project: http://git-wip-us.apache.org/repos/asf/metron/repo
Commit: http://git-wip-us.apache.org/repos/asf/metron/commit/eb5b2d42
Tree: http://git-wip-us.apache.org/repos/asf/metron/tree/eb5b2d42
Diff: http://git-wip-us.apache.org/repos/asf/metron/diff/eb5b2d42

Branch: refs/heads/feature/METRON-1416-upgrade-solr
Commit: eb5b2d42b83901c05c15e00b9c3c5bce5dd72ab9
Parents: ea6992f
Author: cstella <cestella@gmail.com>
Authored: Thu Apr 12 09:33:12 2018 -0400
Committer: cstella <cestella@gmail.com>
Committed: Thu Apr 12 09:33:12 2018 -0400

----------------------------------------------------------------------
 .../java/org/apache/metron/parsers/json/JSONMapParser.java     | 4 ++--
 .../org/apache/metron/parsers/integration/ParserDriver.java    | 6 +++++-
 2 files changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metron/blob/eb5b2d42/metron-platform/metron-parsers/src/main/java/org/apache/metron/parsers/json/JSONMapParser.java
----------------------------------------------------------------------
diff --git a/metron-platform/metron-parsers/src/main/java/org/apache/metron/parsers/json/JSONMapParser.java
b/metron-platform/metron-parsers/src/main/java/org/apache/metron/parsers/json/JSONMapParser.java
index bddf35d..f5d67f9 100644
--- a/metron-platform/metron-parsers/src/main/java/org/apache/metron/parsers/json/JSONMapParser.java
+++ b/metron-platform/metron-parsers/src/main/java/org/apache/metron/parsers/json/JSONMapParser.java
@@ -89,8 +89,7 @@ public class JSONMapParser extends BasicParser {
   public static final String JSONP_QUERY = "jsonpQuery";
 
   private MapStrategy mapStrategy = MapStrategy.DROP;
-  private TypeRef<List<Map<String, Object>>> typeRef = new TypeRef<List<Map<String,
Object>>>() {
-  };
+  private transient TypeRef<List<Map<String, Object>>> typeRef = null;
   private String jsonpQuery = null;
 
 
@@ -99,6 +98,7 @@ public class JSONMapParser extends BasicParser {
     String strategyStr = (String) config.getOrDefault(MAP_STRATEGY_CONFIG, MapStrategy.DROP.name());
     mapStrategy = MapStrategy.valueOf(strategyStr);
     if (config.containsKey(JSONP_QUERY)) {
+      typeRef = new TypeRef<List<Map<String, Object>>>() { };
       jsonpQuery = (String) config.get(JSONP_QUERY);
       Configuration.setDefaults(new Configuration.Defaults() {
 

http://git-wip-us.apache.org/repos/asf/metron/blob/eb5b2d42/metron-platform/metron-parsers/src/test/java/org/apache/metron/parsers/integration/ParserDriver.java
----------------------------------------------------------------------
diff --git a/metron-platform/metron-parsers/src/test/java/org/apache/metron/parsers/integration/ParserDriver.java
b/metron-platform/metron-parsers/src/test/java/org/apache/metron/parsers/integration/ParserDriver.java
index deb0217..b03ea80 100644
--- a/metron-platform/metron-parsers/src/test/java/org/apache/metron/parsers/integration/ParserDriver.java
+++ b/metron-platform/metron-parsers/src/test/java/org/apache/metron/parsers/integration/ParserDriver.java
@@ -18,6 +18,7 @@
 package org.apache.metron.parsers.integration;
 
 import com.google.common.collect.ImmutableList;
+import org.apache.commons.lang.SerializationUtils;
 import org.apache.metron.common.configuration.ConfigurationsUtils;
 import org.apache.metron.common.configuration.FieldValidator;
 import org.apache.metron.common.configuration.ParserConfigurations;
@@ -42,6 +43,7 @@ import org.mockito.Matchers;
 
 import java.io.Closeable;
 import java.io.IOException;
+import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -54,7 +56,7 @@ import static org.mockito.Mockito.when;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class ParserDriver {
+public class ParserDriver implements Serializable {
   private static final Logger LOG = LoggerFactory.getLogger(ParserBolt.class);
   public static class CollectingWriter implements MessageWriter<JSONObject>{
     List<byte[]> output;
@@ -151,6 +153,8 @@ public class ParserDriver {
 
   public ProcessorResult<List<byte[]>> run(List<byte[]> in) {
     ShimParserBolt bolt = new ShimParserBolt(new ArrayList<>());
+    byte[] b = SerializationUtils.serialize(bolt);
+    ShimParserBolt b2 = (ShimParserBolt) SerializationUtils.deserialize(b);
     OutputCollector collector = mock(OutputCollector.class);
     bolt.prepare(null, null, collector);
     for(byte[] record : in) {


Mime
View raw message