Revert the ObjectMapper change in ZKRecordSerializer.

We noticed OOM in the test after this change. And verified that this is causing 
the problem, revert it for now to unblocking test.


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

Branch: refs/heads/master
Commit: 30c0eff3ea04cabb6e3c3fe161fe457100f1868e
Parents: 2f39f38
Author: Jiajun Wang <[email protected]>
Authored: Thu Oct 11 16:58:36 2018 -0700
Committer: Junkai Xue <[email protected]>
Committed: Thu Nov 1 14:38:43 2018 -0700

----------------------------------------------------------------------
 .../org/apache/helix/manager/zk/ZNRecordSerializer.java  | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/30c0eff3/helix-core/src/main/java/org/apache/helix/manager/zk/ZNRecordSerializer.java
----------------------------------------------------------------------
diff --git 
a/helix-core/src/main/java/org/apache/helix/manager/zk/ZNRecordSerializer.java 
b/helix-core/src/main/java/org/apache/helix/manager/zk/ZNRecordSerializer.java
index 0c92224..890bb13 100644
--- 
a/helix-core/src/main/java/org/apache/helix/manager/zk/ZNRecordSerializer.java
+++ 
b/helix-core/src/main/java/org/apache/helix/manager/zk/ZNRecordSerializer.java
@@ -36,7 +36,6 @@ import org.codehaus.jackson.map.SerializationConfig;
 
 public class ZNRecordSerializer implements ZkSerializer {
   private static Logger logger = 
LoggerFactory.getLogger(ZNRecordSerializer.class);
-  private final ObjectMapper _mapper = new ObjectMapper();
 
   private static int getListFieldBound(ZNRecord record) {
     int max = Integer.MAX_VALUE;
@@ -75,14 +74,15 @@ public class ZNRecordSerializer implements ZkSerializer {
     }
 
     // do serialization
-    SerializationConfig serializationConfig = _mapper.getSerializationConfig();
+    ObjectMapper mapper = new ObjectMapper();
+    SerializationConfig serializationConfig = mapper.getSerializationConfig();
     serializationConfig.set(SerializationConfig.Feature.INDENT_OUTPUT, true);
     serializationConfig.set(SerializationConfig.Feature.AUTO_DETECT_FIELDS, 
true);
     
serializationConfig.set(SerializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS,
 true);
     ByteArrayOutputStream baos = new ByteArrayOutputStream();
     byte[] serializedBytes;
     try {
-      _mapper.writeValue(baos, data);
+      mapper.writeValue(baos, data);
       serializedBytes = baos.toByteArray();
       // apply compression if needed
       if (record.getBooleanField("enableCompression", false) || 
serializedBytes.length > ZNRecord.SIZE_LIMIT) {
@@ -111,7 +111,8 @@ public class ZNRecordSerializer implements ZkSerializer {
 
     ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
 
-    DeserializationConfig deserializationConfig = 
_mapper.getDeserializationConfig();
+    ObjectMapper mapper = new ObjectMapper();
+    DeserializationConfig deserializationConfig = 
mapper.getDeserializationConfig();
     
deserializationConfig.set(DeserializationConfig.Feature.AUTO_DETECT_FIELDS, 
true);
     
deserializationConfig.set(DeserializationConfig.Feature.AUTO_DETECT_SETTERS, 
true);
     
deserializationConfig.set(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,
 true);
@@ -121,7 +122,7 @@ public class ZNRecordSerializer implements ZkSerializer {
         byte[] uncompressedBytes = GZipCompressionUtil.uncompress(bais);
         bais = new ByteArrayInputStream(uncompressedBytes);
       }
-      ZNRecord zn = _mapper.readValue(bais, ZNRecord.class);
+      ZNRecord zn = mapper.readValue(bais, ZNRecord.class);
 
       return zn;
     } catch (Exception e) {

Reply via email to