Skip to content

Commit

Permalink
[hotfix] [core] Minor code cleanups in JavaSerializer and SerializerT…
Browse files Browse the repository at this point in the history
…estBase
  • Loading branch information
StephanEwen committed May 11, 2017
1 parent 6f8022e commit 70c48aa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -62,7 +62,7 @@ public void write(Kryo kryo, Output output, T o) {
}
}

@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public T read(Kryo kryo, Input input, Class aClass) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@
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();
Expand Down Expand Up @@ -124,9 +130,15 @@ public void testSnapshotConfigurationAndReconfigure() throws Exception {

@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());
Expand Down

0 comments on commit 70c48aa

Please sign in to comment.