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/05/10 20:39:47 UTC

[7/8] flink git commit: [hotfix] [core] Minor code cleanups in JavaSerializer and SerializerTestBase

[hotfix] [core] Minor code cleanups in JavaSerializer and SerializerTestBase


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

Branch: refs/heads/release-1.3
Commit: 2696cf34411a466154d88b7fa31b92bf568c64c9
Parents: cc3512e
Author: Stephan Ewen <se...@apache.org>
Authored: Wed May 10 11:28:55 2017 +0200
Committer: Stephan Ewen <se...@apache.org>
Committed: Wed May 10 21:08:37 2017 +0200

----------------------------------------------------------------------
 .../java/typeutils/runtime/kryo/JavaSerializer.java |  4 ++--
 .../api/common/typeutils/SerializerTestBase.java    | 16 ++++++++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/2696cf34/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/JavaSerializer.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/JavaSerializer.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/JavaSerializer.java
index a51647c..711c814 100644
--- a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/JavaSerializer.java
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/JavaSerializer.java
@@ -45,7 +45,7 @@ public class JavaSerializer<T> extends Serializer<T> {
 
 	public JavaSerializer() {}
 
-	@SuppressWarnings("unchecked")
+	@SuppressWarnings({"unchecked", "rawtypes"})
 	@Override
 	public void write(Kryo kryo, Output output, T o) {
 		try {
@@ -62,7 +62,7 @@ public class JavaSerializer<T> extends Serializer<T> {
 		}
 	}
 
-	@SuppressWarnings("unchecked")
+	@SuppressWarnings({"unchecked", "rawtypes"})
 	@Override
 	public T read(Kryo kryo, Input input, Class aClass) {
 		try {

http://git-wip-us.apache.org/repos/asf/flink/blob/2696cf34/flink-core/src/test/java/org/apache/flink/api/common/typeutils/SerializerTestBase.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/common/typeutils/SerializerTestBase.java b/flink-core/src/test/java/org/apache/flink/api/common/typeutils/SerializerTestBase.java
index a846703..f2879ac 100644
--- a/flink-core/src/test/java/org/apache/flink/api/common/typeutils/SerializerTestBase.java
+++ b/flink-core/src/test/java/org/apache/flink/api/common/typeutils/SerializerTestBase.java
@@ -55,7 +55,13 @@ import org.junit.Test;
 public abstract class SerializerTestBase<T> extends TestLogger {
 	
 	protected abstract TypeSerializer<T> createSerializer();
-	
+
+	/**
+	 * Gets the expected length for the serializer's {@link TypeSerializer#getLength()} method.
+	 * 
+	 * <p>The expected length should be positive, for fix-length data types, or {@code -1} for
+	 * variable-length types.
+	 */
 	protected abstract int getLength();
 	
 	protected abstract Class<T> getTypeClass();
@@ -124,9 +130,15 @@ public abstract class SerializerTestBase<T> extends TestLogger {
 	
 	@Test
 	public void testGetLength() {
+		final int len = getLength();
+
+		if (len == 0) {
+			fail("Broken serializer test base - zero length cannot be the expected length");
+		}
+
 		try {
 			TypeSerializer<T> serializer = getSerializer();
-			assertEquals(getLength(), serializer.getLength());
+			assertEquals(len, serializer.getLength());
 		}
 		catch (Exception e) {
 			System.err.println(e.getMessage());