Skip to content

Commit

Permalink
[hotfix] [avro] Add test that validates deserialization of Kryo Seria…
Browse files Browse the repository at this point in the history
…lizer in the absence of Avro
  • Loading branch information
StephanEwen committed Nov 3, 2017
1 parent c438e29 commit 87bf578
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.flink.core.memory.DataOutputViewStreamWrapper;
import org.apache.flink.util.InstantiationUtil;
import org.apache.flink.util.Preconditions;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.apache.flink.api.common.ExecutionConfig;
import org.apache.flink.api.common.typeutils.CompatibilityResult;
import org.apache.flink.api.common.typeutils.TypeSerializer;
import org.apache.flink.api.common.typeutils.TypeSerializerConfigSnapshot;
import org.apache.flink.api.common.typeutils.TypeSerializerSerializationUtil;
import org.apache.flink.core.memory.DataInputViewStreamWrapper;
Expand All @@ -29,6 +30,7 @@
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
Expand All @@ -42,6 +44,7 @@
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

Expand All @@ -67,6 +70,22 @@ public void testMigrationStrategyForRemovedAvroDependency() throws Exception {
assertFalse(compatResult.isRequiresMigration());
}

@Test
public void testDeserializingKryoSerializerWithoutAvro() throws Exception {
final String resource = "serialized-kryo-serializer-1.3";

TypeSerializer<?> serializer;

try (InputStream in = getClass().getClassLoader().getResourceAsStream(resource)) {
DataInputViewStreamWrapper inView = new DataInputViewStreamWrapper(in);

serializer = TypeSerializerSerializationUtil.tryReadSerializer(inView, getClass().getClassLoader());
}

assertNotNull(serializer);
assertTrue(serializer instanceof KryoSerializer);
}

/**
* Verifies that reconfiguration result is INCOMPATIBLE if data type has changed.
*/
Expand Down Expand Up @@ -150,7 +169,7 @@ class FakeAvroClass {
DataInputViewStreamWrapper inputView = new DataInputViewStreamWrapper(f)) {

thrown.expectMessage("Could not find required Avro dependency");
FakeAvroClass myTestClass = kryoSerializer.deserialize(inputView);
kryoSerializer.deserialize(inputView);
}
}
}
Expand Down
Binary file not shown.

0 comments on commit 87bf578

Please sign in to comment.