You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by se...@apache.org on 2017/01/11 20:19:42 UTC
[4/8] flink git commit: [FLINK-5442] [streaming] Ensure order of enum
elements in StateDescriptor.Type through a test
[FLINK-5442] [streaming] Ensure order of enum elements in StateDescriptor.Type through a test
This closes #3091
Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/aa0ef2ac
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/aa0ef2ac
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/aa0ef2ac
Branch: refs/heads/master
Commit: aa0ef2ac4b053c6bead7ec61a9f7965a907e2ade
Parents: 2c2f3e2
Author: Stefan Richter <s....@data-artisans.com>
Authored: Tue Jan 10 22:52:58 2017 +0100
Committer: Stephan Ewen <se...@apache.org>
Committed: Wed Jan 11 19:43:47 2017 +0100
----------------------------------------------------------------------
.../flink/api/common/state/StateDescriptor.java | 3 ++-
.../runtime/state/SerializationProxiesTest.java | 16 ++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flink/blob/aa0ef2ac/flink-core/src/main/java/org/apache/flink/api/common/state/StateDescriptor.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/common/state/StateDescriptor.java b/flink-core/src/main/java/org/apache/flink/api/common/state/StateDescriptor.java
index de3cd4e..ad9d417 100644
--- a/flink-core/src/main/java/org/apache/flink/api/common/state/StateDescriptor.java
+++ b/flink-core/src/main/java/org/apache/flink/api/common/state/StateDescriptor.java
@@ -49,8 +49,9 @@ import static java.util.Objects.requireNonNull;
@PublicEvolving
public abstract class StateDescriptor<S extends State, T> implements Serializable {
+ // Do not change the order of the elements in this enum, ordinal is used in serialization
public enum Type {
- VALUE, LIST, REDUCING, FOLDING, @Deprecated UNKNOWN
+ @Deprecated UNKNOWN, VALUE, LIST, REDUCING, FOLDING
}
private static final long serialVersionUID = 1L;
http://git-wip-us.apache.org/repos/asf/flink/blob/aa0ef2ac/flink-runtime/src/test/java/org/apache/flink/runtime/state/SerializationProxiesTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/state/SerializationProxiesTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/state/SerializationProxiesTest.java
index 9211e92..832b022 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/state/SerializationProxiesTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/state/SerializationProxiesTest.java
@@ -96,4 +96,20 @@ public class SerializationProxiesTest {
Assert.assertEquals(name, metaInfo.getStateName());
}
+
+ /**
+ * This test fixes the order of elements in the enum which is important for serialization. Do not modify this test
+ * except if you are entirely sure what you are doing.
+ */
+ @Test
+ public void testFixTypeOrder() {
+ // ensure all elements are covered
+ Assert.assertEquals(5, StateDescriptor.Type.values().length);
+ // fix the order of elements to keep serialization format stable
+ Assert.assertEquals(0, StateDescriptor.Type.UNKNOWN.ordinal());
+ Assert.assertEquals(1, StateDescriptor.Type.VALUE.ordinal());
+ Assert.assertEquals(2, StateDescriptor.Type.LIST.ordinal());
+ Assert.assertEquals(3, StateDescriptor.Type.REDUCING.ordinal());
+ Assert.assertEquals(4, StateDescriptor.Type.FOLDING.ordinal());
+ }
}
\ No newline at end of file