flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmetz...@apache.org
Subject flink git commit: [FLINK-1446] Fix Kryo createInstance() method
Date Mon, 26 Jan 2015 15:18:08 GMT
Repository: flink
Updated Branches:
  refs/heads/master 3bdeab1bf -> 6bb023532


[FLINK-1446] Fix Kryo createInstance() method

This closes #336


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

Branch: refs/heads/master
Commit: 6bb0235320a5bcb556a54efba92ede60ec3ef9d7
Parents: 3bdeab1
Author: Robert Metzger <metzgerr@web.de>
Authored: Sun Jan 25 13:18:25 2015 +0100
Committer: Robert Metzger <rmetzger@apache.org>
Committed: Mon Jan 26 16:17:43 2015 +0100

----------------------------------------------------------------------
 .../api/java/typeutils/runtime/KryoSerializer.java      | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/6bb02353/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/KryoSerializer.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/KryoSerializer.java
b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/KryoSerializer.java
index bec5d59..d9ecda7 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/KryoSerializer.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/KryoSerializer.java
@@ -35,6 +35,7 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.EOFException;
 import java.io.IOException;
+import java.lang.reflect.Modifier;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -120,7 +121,16 @@ public class KryoSerializer<T> extends TypeSerializer<T>
{
 
 	@Override
 	public T createInstance() {
-		return null;
+		if(Modifier.isAbstract(type.getModifiers()) || Modifier.isInterface(type.getModifiers())
) {
+			return null;
+		} else {
+			checkKryoInitialized();
+			try {
+				return kryo.newInstance(type);
+			} catch(Throwable e) {
+				return null;
+			}
+		}
 	}
 
 	@SuppressWarnings("unchecked")


Mime
View raw message