flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trohrm...@apache.org
Subject [1/4] flink git commit: [hotfix] Correct equals & hashCode implementation of KryoSerializer
Date Fri, 19 May 2017 06:11:27 GMT
Repository: flink
Updated Branches:
  refs/heads/release-1.3 51fb7ed79 -> 94111f985


[hotfix] Correct equals & hashCode implementation of KryoSerializer


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

Branch: refs/heads/release-1.3
Commit: 94111f98558274f6c17284ba7a9b627143ac7b1e
Parents: fe5b92f
Author: Till Rohrmann <trohrmann@apache.org>
Authored: Thu May 18 19:16:06 2017 +0200
Committer: Till Rohrmann <trohrmann@apache.org>
Committed: Thu May 18 23:16:27 2017 +0200

----------------------------------------------------------------------
 .../typeutils/runtime/KryoRegistration.java     |  8 ++++++--
 .../typeutils/runtime/kryo/KryoSerializer.java  | 20 +++++++++++---------
 2 files changed, 17 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/94111f98/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/KryoRegistration.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/KryoRegistration.java
b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/KryoRegistration.java
index 882073d..17a49b8 100644
--- a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/KryoRegistration.java
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/KryoRegistration.java
@@ -23,9 +23,9 @@ import com.esotericsoftware.kryo.Serializer;
 import com.esotericsoftware.kryo.factories.ReflectionSerializerFactory;
 import org.apache.flink.annotation.Internal;
 import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.java.typeutils.runtime.KryoRegistrationSerializerConfigSnapshot;
 import org.apache.flink.util.Preconditions;
 
+import javax.annotation.Nullable;
 import java.io.Serializable;
 
 /**
@@ -56,6 +56,7 @@ public class KryoRegistration implements Serializable {
 	 * <p>This can be a dummy serializer {@link KryoRegistrationSerializerConfigSnapshot.DummyKryoSerializerClass}
if
 	 * the serializer class no longer exists when this registration instance was restored.
 	 */
+	@Nullable
 	private final Class<? extends Serializer<?>> serializerClass;
 
 	/**
@@ -65,9 +66,10 @@ public class KryoRegistration implements Serializable {
 	 * <p>This can be a dummy serializer {@link KryoRegistrationSerializerConfigSnapshot.DummyKryoSerializerClass}
if
 	 * the serializer class no longer exists or is no longer valid when this registration instance
was restored.
 	 */
+	@Nullable
 	private final ExecutionConfig.SerializableSerializer<? extends Serializer<?>>
serializableSerializerInstance;
 
-	private SerializerDefinitionType serializerDefinitionType;
+	private final SerializerDefinitionType serializerDefinitionType;
 
 	public KryoRegistration(Class<?> registeredClass) {
 		this.registeredClass = Preconditions.checkNotNull(registeredClass);
@@ -106,10 +108,12 @@ public class KryoRegistration implements Serializable {
 		return serializerDefinitionType;
 	}
 
+	@Nullable
 	public Class<? extends Serializer<?>> getSerializerClass() {
 		return serializerClass;
 	}
 
+	@Nullable
 	public ExecutionConfig.SerializableSerializer<? extends Serializer<?>> getSerializableSerializerInstance()
{
 		return serializableSerializerInstance;
 	}

http://git-wip-us.apache.org/repos/asf/flink/blob/94111f98/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
index 655de76..6730136 100644
--- a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
@@ -276,16 +276,17 @@ public class KryoSerializer<T> extends TypeSerializer<T>
{
 	}
 	
 	// --------------------------------------------------------------------------------------------
-	
+
 	@Override
 	public int hashCode() {
-		return Objects.hash(
-			type,
-			registeredTypes,
-			registeredTypesWithSerializerClasses,
-			defaultSerializerClasses);
+		int result = type.hashCode();
+		result = 31 * result + (kryoRegistrations.hashCode());
+		result = 31 * result + (defaultSerializers.hashCode());
+		result = 31 * result + (defaultSerializerClasses.hashCode());
+
+		return result;
 	}
-	
+
 	@Override
 	public boolean equals(Object obj) {
 		if (obj instanceof KryoSerializer) {
@@ -293,8 +294,9 @@ public class KryoSerializer<T> extends TypeSerializer<T> {
 
 			return other.canEqual(this) &&
 				type == other.type &&
-				kryoRegistrations.equals(other.kryoRegistrations) &&
-				defaultSerializerClasses.equals(other.defaultSerializerClasses);
+				Objects.equals(kryoRegistrations, other.kryoRegistrations) &&
+				Objects.equals(defaultSerializerClasses, other.defaultSerializerClasses) &&
+				Objects.equals(defaultSerializers, other.defaultSerializers);
 		} else {
 			return false;
 		}


Mime
View raw message