From f2bfbc0df92b11459185447728f99fbb3cce7527 Mon Sep 17 00:00:00 2001 From: Abhinay Nagpal Date: Mon, 15 Oct 2012 10:26:19 -0700 Subject: [PATCH] Added check in serializer if writer's schema greater than reader raise an exception --- .../AvroVersionedGenericSerializer.java | 3 +++ .../avro/versioned/SchemaEvolutionValidator.java | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/java/voldemort/serialization/avro/versioned/AvroVersionedGenericSerializer.java b/src/java/voldemort/serialization/avro/versioned/AvroVersionedGenericSerializer.java index 485d020f94..0d90896bd1 100644 --- a/src/java/voldemort/serialization/avro/versioned/AvroVersionedGenericSerializer.java +++ b/src/java/voldemort/serialization/avro/versioned/AvroVersionedGenericSerializer.java @@ -91,6 +91,9 @@ public Object toObject(byte[] bytes) { Integer version = Integer.valueOf(bytes[0]); + if(version > newestVersion) + throw new SerializationException("Client needs to rebootstrap! \n Writer's schema version greater than Reader"); + Schema typeDefWriter = Schema.parse(typeDefVersions.get(version)); byte[] dataBytes = new byte[bytes.length - 1]; diff --git a/src/java/voldemort/serialization/avro/versioned/SchemaEvolutionValidator.java b/src/java/voldemort/serialization/avro/versioned/SchemaEvolutionValidator.java index ad9c6d014e..76a5724f83 100644 --- a/src/java/voldemort/serialization/avro/versioned/SchemaEvolutionValidator.java +++ b/src/java/voldemort/serialization/avro/versioned/SchemaEvolutionValidator.java @@ -1,3 +1,19 @@ +/* + * Copyright 2011 LinkedIn, Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + package voldemort.serialization.avro.versioned; import java.io.File;