Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 974A5200C63 for ; Thu, 11 May 2017 18:19:17 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 95F5B160BB2; Thu, 11 May 2017 16:19:17 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id DDD5D160BCC for ; Thu, 11 May 2017 18:19:16 +0200 (CEST) Received: (qmail 30959 invoked by uid 500); 11 May 2017 16:19:16 -0000 Mailing-List: contact commits-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flink.apache.org Delivered-To: mailing list commits@flink.apache.org Received: (qmail 30928 invoked by uid 99); 11 May 2017 16:19:16 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 May 2017 16:19:16 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D1762DFFB5; Thu, 11 May 2017 16:19:15 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sewen@apache.org To: commits@flink.apache.org Date: Thu, 11 May 2017 16:19:17 -0000 Message-Id: <85f56dd525d244bc954ebd04f94b24fd@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [03/13] flink git commit: [hotfix] [core] Minor code cleanups in JavaSerializer and SerializerTestBase archived-at: Thu, 11 May 2017 16:19:17 -0000 [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/70c48aaa Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/70c48aaa Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/70c48aaa Branch: refs/heads/master Commit: 70c48aaa65a33d1a375ffa5838cf0e9532a4c202 Parents: 6f8022e Author: Stephan Ewen Authored: Wed May 10 11:28:55 2017 +0200 Committer: Stephan Ewen Committed: Thu May 11 12:45:51 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/70c48aaa/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 extends Serializer { 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 extends Serializer { } } - @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/70c48aaa/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 extends TestLogger { protected abstract TypeSerializer createSerializer(); - + + /** + * Gets the expected length for the serializer's {@link TypeSerializer#getLength()} method. + * + *

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 getTypeClass(); @@ -124,9 +130,15 @@ public abstract class SerializerTestBase 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 serializer = getSerializer(); - assertEquals(getLength(), serializer.getLength()); + assertEquals(len, serializer.getLength()); } catch (Exception e) { System.err.println(e.getMessage());