Updating Kryo to 5.0.0-RC9 (#3593)

diff --git a/WORKSPACE b/WORKSPACE
index 8149611..c8975cc 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -68,7 +68,7 @@
         "antlr:antlr:2.7.7",
         "org.apache.zookeeper:zookeeper:3.5.8",
         "io.kubernetes:client-java:" + kubernetes_client_version,
-        "com.esotericsoftware:kryo:3.0.3",
+        "com.esotericsoftware:kryo:5.0.0-RC9",
         "org.apache.avro:avro:1.7.4",
         "org.apache.mesos:mesos:0.22.0",
         "com.hashicorp.nomad:nomad-sdk:0.7.0",
diff --git a/examples/src/java/BUILD b/examples/src/java/BUILD
index 8d9e823..22813fc 100644
--- a/examples/src/java/BUILD
+++ b/examples/src/java/BUILD
@@ -10,6 +10,7 @@
         "//heron/api/src/java:api-java-low-level",
         "//heron/common/src/java:basics-java",
         "//heron/simulator/src/java:simulator-java",
+        "//third_party/java:kryo",
     ],
 )
 
diff --git a/examples/src/java/org/apache/heron/examples/api/AckingTopology.java b/examples/src/java/org/apache/heron/examples/api/AckingTopology.java
index 13a4b4b..12bdfad 100644
--- a/examples/src/java/org/apache/heron/examples/api/AckingTopology.java
+++ b/examples/src/java/org/apache/heron/examples/api/AckingTopology.java
@@ -60,6 +60,8 @@
     Config conf = new Config();
     conf.setDebug(true);
 
+    conf.setSerializationClassName(Config.HERON_KRYO_SERIALIZER_CLASS_NAME);
+
     // Specifies that all tuples will be automatically failed if not acked within 10 seconds
     conf.setMessageTimeoutSecs(10);
 
diff --git a/heron/api/src/java/org/apache/heron/api/serializer/KryoSerializer.java b/heron/api/src/java/org/apache/heron/api/serializer/KryoSerializer.java
index fe7ebf5..7e709dc 100644
--- a/heron/api/src/java/org/apache/heron/api/serializer/KryoSerializer.java
+++ b/heron/api/src/java/org/apache/heron/api/serializer/KryoSerializer.java
@@ -23,7 +23,6 @@
 import java.lang.reflect.InvocationTargetException;
 import java.math.BigInteger;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -35,9 +34,7 @@
 import com.esotericsoftware.kryo.Serializer;
 import com.esotericsoftware.kryo.io.Input;
 import com.esotericsoftware.kryo.io.Output;
-import com.esotericsoftware.kryo.serializers.CollectionSerializer;
 import com.esotericsoftware.kryo.serializers.DefaultSerializers;
-import com.esotericsoftware.kryo.serializers.MapSerializer;
 
 import org.apache.heron.api.Config;
 import org.apache.heron.api.tuple.Values;
@@ -79,7 +76,7 @@
 
   @Override
   public byte[] serialize(Object object) {
-    kryoOut.clear();
+    kryoOut.reset();
     kryo.writeClassAndObject(kryoOut, object);
     return kryoOut.toBytes();
   }
@@ -94,9 +91,9 @@
   private static void registerDefaultSerializers(Kryo k) {
     // Default serializers
     k.register(byte[].class);
-    k.register(ArrayList.class, new ArrayListSerializer());
-    k.register(HashMap.class, new HashMapSerializer());
-    k.register(HashSet.class, new HashSetSerializer());
+    k.register(ArrayList.class);
+    k.register(HashMap.class);
+    k.register(HashSet.class);
     k.register(BigInteger.class, new DefaultSerializers.BigIntegerSerializer());
     k.register(Values.class);
   }
@@ -217,28 +214,4 @@
         String.format("Unable to create serializer \"%s\" for class: %s",
             serializerClass.getName(), superClass.getName()));
   }
-
-  private static class ArrayListSerializer extends CollectionSerializer {
-    @Override
-    @SuppressWarnings("rawtypes") // extending Kryo class that uses raw types
-    public Collection create(Kryo k, Input input, Class<Collection> type) {
-      return new ArrayList();
-    }
-  }
-
-  private static class HashMapSerializer extends MapSerializer {
-    @Override
-    @SuppressWarnings("rawtypes") // extending kryo class signature that takes Map
-    public Map<String, Object> create(Kryo k, Input input, Class<Map> type) {
-      return new HashMap<>();
-    }
-  }
-
-  private static class HashSetSerializer extends CollectionSerializer {
-    @Override
-    @SuppressWarnings("rawtypes") // extending Kryo class that uses raw types
-    public Collection create(Kryo k, Input input, Class<Collection> type) {
-      return new HashSet();
-    }
-  }
 }
diff --git a/maven_install.json b/maven_install.json
index a2da79c..70392fd 100644
--- a/maven_install.json
+++ b/maven_install.json
@@ -1,6 +1,6 @@
 {
     "dependency_tree": {
-        "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": -1332813254,
+        "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": -790274667,
         "conflict_resolution": {},
         "dependencies": [
             {
@@ -374,108 +374,98 @@
                 "url": "https://jcenter.bintray.com/com/beust/jcommander/1.48/jcommander-1.48-sources.jar"
             },
             {
-                "coord": "com.esotericsoftware:kryo:3.0.3",
+                "coord": "com.esotericsoftware:kryo:5.0.0-RC9",
                 "dependencies": [
-                    "com.esotericsoftware:minlog:1.3.0",
-                    "org.objenesis:objenesis:2.1",
-                    "org.ow2.asm:asm:5.0.4",
-                    "com.esotericsoftware:reflectasm:1.10.1"
-                ],
-                "directDependencies": [
-                    "com.esotericsoftware:minlog:1.3.0",
-                    "com.esotericsoftware:reflectasm:1.10.1",
+                    "com.esotericsoftware:minlog:1.3.1",
+                    "com.esotericsoftware:reflectasm:1.11.8",
                     "org.objenesis:objenesis:2.1"
                 ],
-                "file": "v1/https/jcenter.bintray.com/com/esotericsoftware/kryo/3.0.3/kryo-3.0.3.jar",
-                "mirror_urls": [
-                    "https://jcenter.bintray.com/com/esotericsoftware/kryo/3.0.3/kryo-3.0.3.jar",
-                    "https://maven.google.com/com/esotericsoftware/kryo/3.0.3/kryo-3.0.3.jar",
-                    "https://repo1.maven.org/maven2/com/esotericsoftware/kryo/3.0.3/kryo-3.0.3.jar"
+                "directDependencies": [
+                    "com.esotericsoftware:minlog:1.3.1",
+                    "com.esotericsoftware:reflectasm:1.11.8",
+                    "org.objenesis:objenesis:2.1"
                 ],
-                "sha256": "5c295b23480225ff6e7d6770dfa904bedcec8556c27234fea0a271fe13195f69",
-                "url": "https://jcenter.bintray.com/com/esotericsoftware/kryo/3.0.3/kryo-3.0.3.jar"
+                "file": "v1/https/jcenter.bintray.com/com/esotericsoftware/kryo/5.0.0-RC9/kryo-5.0.0-RC9.jar",
+                "mirror_urls": [
+                    "https://jcenter.bintray.com/com/esotericsoftware/kryo/5.0.0-RC9/kryo-5.0.0-RC9.jar",
+                    "https://maven.google.com/com/esotericsoftware/kryo/5.0.0-RC9/kryo-5.0.0-RC9.jar",
+                    "https://repo1.maven.org/maven2/com/esotericsoftware/kryo/5.0.0-RC9/kryo-5.0.0-RC9.jar"
+                ],
+                "sha256": "3d9ef4b1e3c1741e5a59938b8e730b950dbed99b171103b61088cb2d66f3987d",
+                "url": "https://jcenter.bintray.com/com/esotericsoftware/kryo/5.0.0-RC9/kryo-5.0.0-RC9.jar"
             },
             {
-                "coord": "com.esotericsoftware:kryo:jar:sources:3.0.3",
+                "coord": "com.esotericsoftware:kryo:jar:sources:5.0.0-RC9",
                 "dependencies": [
-                    "com.esotericsoftware:minlog:jar:sources:1.3.0",
-                    "com.esotericsoftware:reflectasm:jar:sources:1.10.1",
-                    "org.objenesis:objenesis:jar:sources:2.1",
-                    "org.ow2.asm:asm:jar:sources:5.0.4"
-                ],
-                "directDependencies": [
-                    "com.esotericsoftware:minlog:jar:sources:1.3.0",
-                    "com.esotericsoftware:reflectasm:jar:sources:1.10.1",
+                    "com.esotericsoftware:reflectasm:jar:sources:1.11.8",
+                    "com.esotericsoftware:minlog:jar:sources:1.3.1",
                     "org.objenesis:objenesis:jar:sources:2.1"
                 ],
-                "file": "v1/https/jcenter.bintray.com/com/esotericsoftware/kryo/3.0.3/kryo-3.0.3-sources.jar",
-                "mirror_urls": [
-                    "https://jcenter.bintray.com/com/esotericsoftware/kryo/3.0.3/kryo-3.0.3-sources.jar",
-                    "https://maven.google.com/com/esotericsoftware/kryo/3.0.3/kryo-3.0.3-sources.jar",
-                    "https://repo1.maven.org/maven2/com/esotericsoftware/kryo/3.0.3/kryo-3.0.3-sources.jar"
+                "directDependencies": [
+                    "com.esotericsoftware:minlog:jar:sources:1.3.1",
+                    "com.esotericsoftware:reflectasm:jar:sources:1.11.8",
+                    "org.objenesis:objenesis:jar:sources:2.1"
                 ],
-                "sha256": "5a02ca261f78e21ad030e5f8ac5dc61bf93160128e53d98ef0be41dbe6dbf4a6",
-                "url": "https://jcenter.bintray.com/com/esotericsoftware/kryo/3.0.3/kryo-3.0.3-sources.jar"
+                "file": "v1/https/jcenter.bintray.com/com/esotericsoftware/kryo/5.0.0-RC9/kryo-5.0.0-RC9-sources.jar",
+                "mirror_urls": [
+                    "https://jcenter.bintray.com/com/esotericsoftware/kryo/5.0.0-RC9/kryo-5.0.0-RC9-sources.jar",
+                    "https://maven.google.com/com/esotericsoftware/kryo/5.0.0-RC9/kryo-5.0.0-RC9-sources.jar",
+                    "https://repo1.maven.org/maven2/com/esotericsoftware/kryo/5.0.0-RC9/kryo-5.0.0-RC9-sources.jar"
+                ],
+                "sha256": "c26d03e45c3840341a1e5ac953f1fa1e3c7c958eb9e129b5014cadff88663e5b",
+                "url": "https://jcenter.bintray.com/com/esotericsoftware/kryo/5.0.0-RC9/kryo-5.0.0-RC9-sources.jar"
             },
             {
-                "coord": "com.esotericsoftware:minlog:1.3.0",
+                "coord": "com.esotericsoftware:minlog:1.3.1",
                 "dependencies": [],
                 "directDependencies": [],
-                "file": "v1/https/jcenter.bintray.com/com/esotericsoftware/minlog/1.3.0/minlog-1.3.0.jar",
+                "file": "v1/https/jcenter.bintray.com/com/esotericsoftware/minlog/1.3.1/minlog-1.3.1.jar",
                 "mirror_urls": [
-                    "https://jcenter.bintray.com/com/esotericsoftware/minlog/1.3.0/minlog-1.3.0.jar",
-                    "https://maven.google.com/com/esotericsoftware/minlog/1.3.0/minlog-1.3.0.jar",
-                    "https://repo1.maven.org/maven2/com/esotericsoftware/minlog/1.3.0/minlog-1.3.0.jar"
+                    "https://jcenter.bintray.com/com/esotericsoftware/minlog/1.3.1/minlog-1.3.1.jar",
+                    "https://maven.google.com/com/esotericsoftware/minlog/1.3.1/minlog-1.3.1.jar",
+                    "https://repo1.maven.org/maven2/com/esotericsoftware/minlog/1.3.1/minlog-1.3.1.jar"
                 ],
-                "sha256": "f7b399d3a5478a4f3e0d98bd1c9f47766119c66414bc33aa0f6cde0066f24cc2",
-                "url": "https://jcenter.bintray.com/com/esotericsoftware/minlog/1.3.0/minlog-1.3.0.jar"
+                "sha256": "5d4d632cfbebfe0a7644501cc303570b691406181bee65e9916b921c767d7c72",
+                "url": "https://jcenter.bintray.com/com/esotericsoftware/minlog/1.3.1/minlog-1.3.1.jar"
             },
             {
-                "coord": "com.esotericsoftware:minlog:jar:sources:1.3.0",
+                "coord": "com.esotericsoftware:minlog:jar:sources:1.3.1",
                 "dependencies": [],
                 "directDependencies": [],
-                "file": "v1/https/jcenter.bintray.com/com/esotericsoftware/minlog/1.3.0/minlog-1.3.0-sources.jar",
+                "file": "v1/https/jcenter.bintray.com/com/esotericsoftware/minlog/1.3.1/minlog-1.3.1-sources.jar",
                 "mirror_urls": [
-                    "https://jcenter.bintray.com/com/esotericsoftware/minlog/1.3.0/minlog-1.3.0-sources.jar",
-                    "https://maven.google.com/com/esotericsoftware/minlog/1.3.0/minlog-1.3.0-sources.jar",
-                    "https://repo1.maven.org/maven2/com/esotericsoftware/minlog/1.3.0/minlog-1.3.0-sources.jar"
+                    "https://jcenter.bintray.com/com/esotericsoftware/minlog/1.3.1/minlog-1.3.1-sources.jar",
+                    "https://maven.google.com/com/esotericsoftware/minlog/1.3.1/minlog-1.3.1-sources.jar",
+                    "https://repo1.maven.org/maven2/com/esotericsoftware/minlog/1.3.1/minlog-1.3.1-sources.jar"
                 ],
-                "sha256": "99872e1e68874771d77bf3131620bf656b541fa993d3f6e9d29b9f03ae423d17",
-                "url": "https://jcenter.bintray.com/com/esotericsoftware/minlog/1.3.0/minlog-1.3.0-sources.jar"
+                "sha256": "fdaf83a8c51295eff3a8109473ce7b213582738f71593e16b1efa012ff1f99b5",
+                "url": "https://jcenter.bintray.com/com/esotericsoftware/minlog/1.3.1/minlog-1.3.1-sources.jar"
             },
             {
-                "coord": "com.esotericsoftware:reflectasm:1.10.1",
-                "dependencies": [
-                    "org.ow2.asm:asm:5.0.4"
-                ],
-                "directDependencies": [
-                    "org.ow2.asm:asm:5.0.4"
-                ],
-                "file": "v1/https/jcenter.bintray.com/com/esotericsoftware/reflectasm/1.10.1/reflectasm-1.10.1.jar",
+                "coord": "com.esotericsoftware:reflectasm:1.11.8",
+                "dependencies": [],
+                "directDependencies": [],
+                "file": "v1/https/jcenter.bintray.com/com/esotericsoftware/reflectasm/1.11.8/reflectasm-1.11.8.jar",
                 "mirror_urls": [
-                    "https://jcenter.bintray.com/com/esotericsoftware/reflectasm/1.10.1/reflectasm-1.10.1.jar",
-                    "https://maven.google.com/com/esotericsoftware/reflectasm/1.10.1/reflectasm-1.10.1.jar",
-                    "https://repo1.maven.org/maven2/com/esotericsoftware/reflectasm/1.10.1/reflectasm-1.10.1.jar"
+                    "https://jcenter.bintray.com/com/esotericsoftware/reflectasm/1.11.8/reflectasm-1.11.8.jar",
+                    "https://maven.google.com/com/esotericsoftware/reflectasm/1.11.8/reflectasm-1.11.8.jar",
+                    "https://repo1.maven.org/maven2/com/esotericsoftware/reflectasm/1.11.8/reflectasm-1.11.8.jar"
                 ],
-                "sha256": "94867942701229aead2b99cfbfdb68ea0afe4ec6fb943e5a10cb875f6e94f5b4",
-                "url": "https://jcenter.bintray.com/com/esotericsoftware/reflectasm/1.10.1/reflectasm-1.10.1.jar"
+                "sha256": "d91dc2db686c0389763ae2253e43cfd1c7e175efcceeb3c59778d6deb86bef90",
+                "url": "https://jcenter.bintray.com/com/esotericsoftware/reflectasm/1.11.8/reflectasm-1.11.8.jar"
             },
             {
-                "coord": "com.esotericsoftware:reflectasm:jar:sources:1.10.1",
-                "dependencies": [
-                    "org.ow2.asm:asm:jar:sources:5.0.4"
-                ],
-                "directDependencies": [
-                    "org.ow2.asm:asm:jar:sources:5.0.4"
-                ],
-                "file": "v1/https/jcenter.bintray.com/com/esotericsoftware/reflectasm/1.10.1/reflectasm-1.10.1-sources.jar",
+                "coord": "com.esotericsoftware:reflectasm:jar:sources:1.11.8",
+                "dependencies": [],
+                "directDependencies": [],
+                "file": "v1/https/jcenter.bintray.com/com/esotericsoftware/reflectasm/1.11.8/reflectasm-1.11.8-sources.jar",
                 "mirror_urls": [
-                    "https://jcenter.bintray.com/com/esotericsoftware/reflectasm/1.10.1/reflectasm-1.10.1-sources.jar",
-                    "https://maven.google.com/com/esotericsoftware/reflectasm/1.10.1/reflectasm-1.10.1-sources.jar",
-                    "https://repo1.maven.org/maven2/com/esotericsoftware/reflectasm/1.10.1/reflectasm-1.10.1-sources.jar"
+                    "https://jcenter.bintray.com/com/esotericsoftware/reflectasm/1.11.8/reflectasm-1.11.8-sources.jar",
+                    "https://maven.google.com/com/esotericsoftware/reflectasm/1.11.8/reflectasm-1.11.8-sources.jar",
+                    "https://repo1.maven.org/maven2/com/esotericsoftware/reflectasm/1.11.8/reflectasm-1.11.8-sources.jar"
                 ],
-                "sha256": "5d46267d7130e2d5963472dbb2a975ae764ec9f616c1c9b7e7961fcc600d38a0",
-                "url": "https://jcenter.bintray.com/com/esotericsoftware/reflectasm/1.10.1/reflectasm-1.10.1-sources.jar"
+                "sha256": "f5261244cee0661d1dc0ae4c465e13654e3ee787ce32e25e784f32b51d13ce58",
+                "url": "https://jcenter.bintray.com/com/esotericsoftware/reflectasm/1.11.8/reflectasm-1.11.8-sources.jar"
             },
             {
                 "coord": "com.fasterxml.jackson.core:jackson-annotations:2.8.8",
diff --git a/release/maven/heron-with-kryo.template.pom b/release/maven/heron-with-kryo.template.pom
index 6413908..40bbd68 100644
--- a/release/maven/heron-with-kryo.template.pom
+++ b/release/maven/heron-with-kryo.template.pom
@@ -36,7 +36,7 @@
     <dependency>
       <groupId>com.esotericsoftware</groupId>
       <artifactId>kryo</artifactId>
-      <version>3.0.3</version>
+      <version>5.0.0-RC9</version>
       <scope>compile</scope>
     </dependency>
   </dependencies>
diff --git a/storm-compatibility/v0.10.2/src/java/backtype/storm/serialization/HeronPluggableSerializerDelegate.java b/storm-compatibility/v0.10.2/src/java/backtype/storm/serialization/HeronPluggableSerializerDelegate.java
index bc0daef..382f9f5 100644
--- a/storm-compatibility/v0.10.2/src/java/backtype/storm/serialization/HeronPluggableSerializerDelegate.java
+++ b/storm-compatibility/v0.10.2/src/java/backtype/storm/serialization/HeronPluggableSerializerDelegate.java
@@ -44,7 +44,7 @@
 
   @Override
   public byte[] serialize(Object object) {
-    kryoOut.clear();
+    kryoOut.reset();
     kryo.writeClassAndObject(kryoOut, object);
     return kryoOut.toBytes();
   }
diff --git a/storm-compatibility/v0.10.2/src/java/backtype/storm/serialization/SerializationFactory.java b/storm-compatibility/v0.10.2/src/java/backtype/storm/serialization/SerializationFactory.java
index 8ed559f..5188853 100644
--- a/storm-compatibility/v0.10.2/src/java/backtype/storm/serialization/SerializationFactory.java
+++ b/storm-compatibility/v0.10.2/src/java/backtype/storm/serialization/SerializationFactory.java
@@ -35,9 +35,6 @@
 import com.esotericsoftware.kryo.serializers.DefaultSerializers.BigIntegerSerializer;
 
 import backtype.storm.Config;
-import backtype.storm.serialization.types.ArrayListSerializer;
-import backtype.storm.serialization.types.HashMapSerializer;
-import backtype.storm.serialization.types.HashSetSerializer;
 import backtype.storm.tuple.Values;
 import backtype.storm.utils.ListDelegate;
 import backtype.storm.utils.Utils;
@@ -60,9 +57,9 @@
     Kryo k = kryoFactory.getKryo(conf);
     k.register(byte[].class);
     k.register(ListDelegate.class);
-    k.register(ArrayList.class, new ArrayListSerializer());
-    k.register(HashMap.class, new HashMapSerializer());
-    k.register(HashSet.class, new HashSetSerializer());
+    k.register(ArrayList.class);
+    k.register(HashMap.class);
+    k.register(HashSet.class);
     k.register(BigInteger.class, new BigIntegerSerializer());
     // k.register(TransactionAttempt.class);
     k.register(Values.class);
diff --git a/storm-compatibility/v0.10.2/src/java/backtype/storm/serialization/types/ArrayListSerializer.java b/storm-compatibility/v0.10.2/src/java/backtype/storm/serialization/types/ArrayListSerializer.java
deleted file mode 100644
index 28b885d..0000000
--- a/storm-compatibility/v0.10.2/src/java/backtype/storm/serialization/types/ArrayListSerializer.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package backtype.storm.serialization.types;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import com.esotericsoftware.kryo.Kryo;
-import com.esotericsoftware.kryo.io.Input;
-import com.esotericsoftware.kryo.serializers.CollectionSerializer;
-
-
-public class ArrayListSerializer extends CollectionSerializer {
-  @Override
-  @SuppressWarnings("rawtypes") // extending Kryo class that uses raw types
-  public Collection create(Kryo kryo, Input input, Class<Collection> type) {
-    return new ArrayList();
-  }
-}
diff --git a/storm-compatibility/v0.10.2/src/java/backtype/storm/serialization/types/HashMapSerializer.java b/storm-compatibility/v0.10.2/src/java/backtype/storm/serialization/types/HashMapSerializer.java
deleted file mode 100644
index 8e95658..0000000
--- a/storm-compatibility/v0.10.2/src/java/backtype/storm/serialization/types/HashMapSerializer.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package backtype.storm.serialization.types;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.esotericsoftware.kryo.Kryo;
-import com.esotericsoftware.kryo.io.Input;
-import com.esotericsoftware.kryo.serializers.MapSerializer;
-
-
-public class HashMapSerializer extends MapSerializer {
-  @Override
-  @SuppressWarnings("rawtypes") // extending kryo class signature that takes Map
-  public Map<String, Object> create(Kryo kryo, Input input, Class<Map> type) {
-    return new HashMap<String, Object>();
-  }
-}
diff --git a/storm-compatibility/v0.10.2/src/java/backtype/storm/serialization/types/HashSetSerializer.java b/storm-compatibility/v0.10.2/src/java/backtype/storm/serialization/types/HashSetSerializer.java
deleted file mode 100644
index 824bf04..0000000
--- a/storm-compatibility/v0.10.2/src/java/backtype/storm/serialization/types/HashSetSerializer.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package backtype.storm.serialization.types;
-
-import java.util.Collection;
-import java.util.HashSet;
-
-import com.esotericsoftware.kryo.Kryo;
-import com.esotericsoftware.kryo.io.Input;
-import com.esotericsoftware.kryo.serializers.CollectionSerializer;
-
-
-public class HashSetSerializer extends CollectionSerializer {
-  @Override
-  @SuppressWarnings("rawtypes") // extending Kryo class that uses raw types
-  public Collection create(Kryo kryo, Input input, Class<Collection> type) {
-    return new HashSet();
-  }
-}
diff --git a/storm-compatibility/v0.10.2/src/java/org/apache/storm/serialization/HeronPluggableSerializerDelegate.java b/storm-compatibility/v0.10.2/src/java/org/apache/storm/serialization/HeronPluggableSerializerDelegate.java
index 6ad7569..5731af5 100644
--- a/storm-compatibility/v0.10.2/src/java/org/apache/storm/serialization/HeronPluggableSerializerDelegate.java
+++ b/storm-compatibility/v0.10.2/src/java/org/apache/storm/serialization/HeronPluggableSerializerDelegate.java
@@ -44,7 +44,7 @@
 
   @Override
   public byte[] serialize(Object object) {
-    kryoOut.clear();
+    kryoOut.reset();
     kryo.writeClassAndObject(kryoOut, object);
     return kryoOut.toBytes();
   }
diff --git a/storm-compatibility/v0.10.2/src/java/org/apache/storm/serialization/SerializationFactory.java b/storm-compatibility/v0.10.2/src/java/org/apache/storm/serialization/SerializationFactory.java
index 47102a6..27d2775 100644
--- a/storm-compatibility/v0.10.2/src/java/org/apache/storm/serialization/SerializationFactory.java
+++ b/storm-compatibility/v0.10.2/src/java/org/apache/storm/serialization/SerializationFactory.java
@@ -35,9 +35,6 @@
 import com.esotericsoftware.kryo.serializers.DefaultSerializers.BigIntegerSerializer;
 
 import org.apache.storm.Config;
-import org.apache.storm.serialization.types.ArrayListSerializer;
-import org.apache.storm.serialization.types.HashMapSerializer;
-import org.apache.storm.serialization.types.HashSetSerializer;
 import org.apache.storm.tuple.Values;
 import org.apache.storm.utils.ListDelegate;
 import org.apache.storm.utils.Utils;
@@ -61,9 +58,9 @@
     Kryo k = kryoFactory.getKryo(conf);
     k.register(byte[].class);
     k.register(ListDelegate.class);
-    k.register(ArrayList.class, new ArrayListSerializer());
-    k.register(HashMap.class, new HashMapSerializer());
-    k.register(HashSet.class, new HashSetSerializer());
+    k.register(ArrayList.class);
+    k.register(HashMap.class);
+    k.register(HashSet.class);
     k.register(BigInteger.class, new BigIntegerSerializer());
     // k.register(TransactionAttempt.class);
     k.register(Values.class);
diff --git a/storm-compatibility/v0.10.2/src/java/org/apache/storm/serialization/types/ArrayListSerializer.java b/storm-compatibility/v0.10.2/src/java/org/apache/storm/serialization/types/ArrayListSerializer.java
deleted file mode 100644
index 427bd6f..0000000
--- a/storm-compatibility/v0.10.2/src/java/org/apache/storm/serialization/types/ArrayListSerializer.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.storm.serialization.types;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import com.esotericsoftware.kryo.Kryo;
-import com.esotericsoftware.kryo.io.Input;
-import com.esotericsoftware.kryo.serializers.CollectionSerializer;
-
-
-public class ArrayListSerializer extends CollectionSerializer {
-  @Override
-  @SuppressWarnings("rawtypes") // extending Kryo class that uses raw types
-  public Collection create(Kryo kryo, Input input, Class<Collection> type) {
-    return new ArrayList();
-  }
-}
diff --git a/storm-compatibility/v0.10.2/src/java/org/apache/storm/serialization/types/HashMapSerializer.java b/storm-compatibility/v0.10.2/src/java/org/apache/storm/serialization/types/HashMapSerializer.java
deleted file mode 100644
index c75b93a..0000000
--- a/storm-compatibility/v0.10.2/src/java/org/apache/storm/serialization/types/HashMapSerializer.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.storm.serialization.types;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.esotericsoftware.kryo.Kryo;
-import com.esotericsoftware.kryo.io.Input;
-import com.esotericsoftware.kryo.serializers.MapSerializer;
-
-
-public class HashMapSerializer extends MapSerializer {
-  @Override
-  @SuppressWarnings("rawtypes") // extending Kryo class that uses raw types
-  public Map create(Kryo kryo, Input input, Class<Map> type) {
-    return new HashMap();
-  }
-}
diff --git a/storm-compatibility/v0.10.2/src/java/org/apache/storm/serialization/types/HashSetSerializer.java b/storm-compatibility/v0.10.2/src/java/org/apache/storm/serialization/types/HashSetSerializer.java
deleted file mode 100644
index cf41a6f..0000000
--- a/storm-compatibility/v0.10.2/src/java/org/apache/storm/serialization/types/HashSetSerializer.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.storm.serialization.types;
-
-import java.util.Collection;
-import java.util.HashSet;
-
-import com.esotericsoftware.kryo.Kryo;
-import com.esotericsoftware.kryo.io.Input;
-import com.esotericsoftware.kryo.serializers.CollectionSerializer;
-
-
-public class HashSetSerializer extends CollectionSerializer {
-  @Override
-  @SuppressWarnings("rawtypes") // extending Kryo class that uses raw types
-  public Collection create(Kryo kryo, Input input, Class<Collection> type) {
-    return new HashSet();
-  }
-}
diff --git a/storm-compatibility/v2.2.0/src/java/org/apache/storm/serialization/HeronPluggableSerializerDelegate.java b/storm-compatibility/v2.2.0/src/java/org/apache/storm/serialization/HeronPluggableSerializerDelegate.java
index 6ad7569..5731af5 100644
--- a/storm-compatibility/v2.2.0/src/java/org/apache/storm/serialization/HeronPluggableSerializerDelegate.java
+++ b/storm-compatibility/v2.2.0/src/java/org/apache/storm/serialization/HeronPluggableSerializerDelegate.java
@@ -44,7 +44,7 @@
 
   @Override
   public byte[] serialize(Object object) {
-    kryoOut.clear();
+    kryoOut.reset();
     kryo.writeClassAndObject(kryoOut, object);
     return kryoOut.toBytes();
   }
diff --git a/storm-compatibility/v2.2.0/src/java/org/apache/storm/serialization/SerializationFactory.java b/storm-compatibility/v2.2.0/src/java/org/apache/storm/serialization/SerializationFactory.java
index 47102a6..059323e 100644
--- a/storm-compatibility/v2.2.0/src/java/org/apache/storm/serialization/SerializationFactory.java
+++ b/storm-compatibility/v2.2.0/src/java/org/apache/storm/serialization/SerializationFactory.java
@@ -32,12 +32,10 @@
 
 import com.esotericsoftware.kryo.Kryo;
 import com.esotericsoftware.kryo.Serializer;
+import com.esotericsoftware.kryo.serializers.CollectionSerializer;
 import com.esotericsoftware.kryo.serializers.DefaultSerializers.BigIntegerSerializer;
 
 import org.apache.storm.Config;
-import org.apache.storm.serialization.types.ArrayListSerializer;
-import org.apache.storm.serialization.types.HashMapSerializer;
-import org.apache.storm.serialization.types.HashSetSerializer;
 import org.apache.storm.tuple.Values;
 import org.apache.storm.utils.ListDelegate;
 import org.apache.storm.utils.Utils;
@@ -61,9 +59,9 @@
     Kryo k = kryoFactory.getKryo(conf);
     k.register(byte[].class);
     k.register(ListDelegate.class);
-    k.register(ArrayList.class, new ArrayListSerializer());
-    k.register(HashMap.class, new HashMapSerializer());
-    k.register(HashSet.class, new HashSetSerializer());
+    k.register(ArrayList.class);
+    k.register(HashMap.class);
+    k.register(HashSet.class);
     k.register(BigInteger.class, new BigIntegerSerializer());
     // k.register(TransactionAttempt.class);
     k.register(Values.class);
@@ -166,8 +164,8 @@
     }
 
     try {
-      return serializerClass.newInstance();
-    } catch (InstantiationException | IllegalAccessException ex) {
+      return serializerClass.getDeclaredConstructor().newInstance();
+    } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException ex) {
       // do nothing
     }
 
diff --git a/storm-compatibility/v2.2.0/src/java/org/apache/storm/serialization/types/ArrayListSerializer.java b/storm-compatibility/v2.2.0/src/java/org/apache/storm/serialization/types/ArrayListSerializer.java
deleted file mode 100644
index 427bd6f..0000000
--- a/storm-compatibility/v2.2.0/src/java/org/apache/storm/serialization/types/ArrayListSerializer.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.storm.serialization.types;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import com.esotericsoftware.kryo.Kryo;
-import com.esotericsoftware.kryo.io.Input;
-import com.esotericsoftware.kryo.serializers.CollectionSerializer;
-
-
-public class ArrayListSerializer extends CollectionSerializer {
-  @Override
-  @SuppressWarnings("rawtypes") // extending Kryo class that uses raw types
-  public Collection create(Kryo kryo, Input input, Class<Collection> type) {
-    return new ArrayList();
-  }
-}
diff --git a/storm-compatibility/v2.2.0/src/java/org/apache/storm/serialization/types/HashMapSerializer.java b/storm-compatibility/v2.2.0/src/java/org/apache/storm/serialization/types/HashMapSerializer.java
deleted file mode 100644
index c75b93a..0000000
--- a/storm-compatibility/v2.2.0/src/java/org/apache/storm/serialization/types/HashMapSerializer.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.storm.serialization.types;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.esotericsoftware.kryo.Kryo;
-import com.esotericsoftware.kryo.io.Input;
-import com.esotericsoftware.kryo.serializers.MapSerializer;
-
-
-public class HashMapSerializer extends MapSerializer {
-  @Override
-  @SuppressWarnings("rawtypes") // extending Kryo class that uses raw types
-  public Map create(Kryo kryo, Input input, Class<Map> type) {
-    return new HashMap();
-  }
-}
diff --git a/storm-compatibility/v2.2.0/src/java/org/apache/storm/serialization/types/HashSetSerializer.java b/storm-compatibility/v2.2.0/src/java/org/apache/storm/serialization/types/HashSetSerializer.java
deleted file mode 100644
index cf41a6f..0000000
--- a/storm-compatibility/v2.2.0/src/java/org/apache/storm/serialization/types/HashSetSerializer.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.storm.serialization.types;
-
-import java.util.Collection;
-import java.util.HashSet;
-
-import com.esotericsoftware.kryo.Kryo;
-import com.esotericsoftware.kryo.io.Input;
-import com.esotericsoftware.kryo.serializers.CollectionSerializer;
-
-
-public class HashSetSerializer extends CollectionSerializer {
-  @Override
-  @SuppressWarnings("rawtypes") // extending Kryo class that uses raw types
-  public Collection create(Kryo kryo, Input input, Class<Collection> type) {
-    return new HashSet();
-  }
-}