From d26043a0984b52d7bb9129f10944f1b191724569 Mon Sep 17 00:00:00 2001 From: Shivesh Ranjan Date: Fri, 31 Jul 2020 09:51:30 -0700 Subject: [PATCH] use Array.equals Signed-off-by: Shivesh Ranjan --- .../service/SchemaRegistryService.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/io/pravega/schemaregistry/service/SchemaRegistryService.java b/server/src/main/java/io/pravega/schemaregistry/service/SchemaRegistryService.java index 1d27f687c..b2de13354 100644 --- a/server/src/main/java/io/pravega/schemaregistry/service/SchemaRegistryService.java +++ b/server/src/main/java/io/pravega/schemaregistry/service/SchemaRegistryService.java @@ -58,6 +58,7 @@ import java.math.BigInteger; import java.nio.ByteBuffer; import java.util.AbstractMap; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; @@ -1003,7 +1004,20 @@ boolean compareNormalized(SchemaInfo schemaInfo) { Preconditions.checkNotNull(schemaInfo, "Supply non null Schemainfo."); return schemaInfo.getType().equals(normalized.getType()) && schemaInfo.getSerializationFormat().equals(normalized.getSerializationFormat()) && - normalizeSchemaBinary(schemaInfo).parsedSchema.equals(this.parsedSchema); + compareParsedSchemas(schemaInfo); + } + + private boolean compareParsedSchemas(SchemaInfo schemaInfo) { + switch (schemaInfo.getSerializationFormat()) { + case Avro: + case Protobuf: + case Json: + return normalizeSchemaBinary(schemaInfo).parsedSchema.equals(this.parsedSchema); + case Any: + case Custom: + default: + return Arrays.equals(schemaInfo.getSchemaData().array(), this.normalized.getSchemaData().array()); + } } } }