flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tzuli...@apache.org
Subject [3/4] flink git commit: [FLINK-6493] Fix ineffective null check in RegisteredOperatorBackendStateMetaInfo#equals
Date Fri, 04 Aug 2017 02:33:37 GMT
[FLINK-6493] Fix ineffective null check in RegisteredOperatorBackendStateMetaInfo#equals


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

Branch: refs/heads/master
Commit: 2248103e5b374507f2fb67c180c928352ae7f02b
Parents: bef7484
Author: zhangminglei <zml13856086071@163.com>
Authored: Thu Aug 3 20:32:35 2017 +0800
Committer: Tzu-Li (Gordon) Tai <tzulitai@apache.org>
Committed: Thu Aug 3 23:14:04 2017 +0800

----------------------------------------------------------------------
 .../RegisteredOperatorBackendStateMetaInfo.java   | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/2248103e/flink-runtime/src/main/java/org/apache/flink/runtime/state/RegisteredOperatorBackendStateMetaInfo.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/state/RegisteredOperatorBackendStateMetaInfo.java
b/flink-runtime/src/main/java/org/apache/flink/runtime/state/RegisteredOperatorBackendStateMetaInfo.java
index b43fc9c..7c56851 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/state/RegisteredOperatorBackendStateMetaInfo.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/state/RegisteredOperatorBackendStateMetaInfo.java
@@ -18,6 +18,7 @@
 
 package org.apache.flink.runtime.state;
 
+import java.util.Objects;
 import org.apache.flink.api.common.typeutils.TypeSerializer;
 import org.apache.flink.api.common.typeutils.TypeSerializerConfigSnapshot;
 import org.apache.flink.util.Preconditions;
@@ -175,14 +176,17 @@ public class RegisteredOperatorBackendStateMetaInfo<S> {
 				return false;
 			}
 
+			if (!(obj instanceof Snapshot)) {
+				return false;
+			}
+
+			Snapshot snapshot = (Snapshot)obj;
+
 			// need to check for nulls because serializer and config snapshots may be null on restore
-			return (obj instanceof Snapshot)
-				&& name.equals(((Snapshot) obj).getName())
-				&& assignmentMode.equals(((Snapshot) obj).getAssignmentMode())
-				&& ((partitionStateSerializer == null && ((Snapshot) obj).getPartitionStateSerializer()
== null)
-					|| partitionStateSerializer.equals(((Snapshot) obj).getPartitionStateSerializer()))
-				&& ((partitionStateSerializerConfigSnapshot == null && ((Snapshot) obj).getPartitionStateSerializerConfigSnapshot()
== null)
-					|| partitionStateSerializerConfigSnapshot.equals(((Snapshot) obj).getPartitionStateSerializerConfigSnapshot()));
+			return name.equals(snapshot.getName())
+				&& assignmentMode.equals(snapshot.getAssignmentMode())
+				&& (Objects.equals(partitionStateSerializer, snapshot.getPartitionStateSerializer()))
+				&& (Objects.equals(partitionStateSerializerConfigSnapshot, snapshot.getPartitionStateSerializerConfigSnapshot()));
 		}
 
 		@Override


Mime
View raw message