in avro-kafkaconnect-converter/src/main/java/com/amazonaws/services/schemaregistry/kafkaconnect/avrodata/AvroData.java [2175:2216]
private static boolean schemaEquals(Schema src, Schema that, Map<SchemaPair, Boolean> cache) {
if (src == that) {
return true;
} else if (src == null || that == null) {
return false;
}
// Add a temporary value to the cache to avoid cycles. As long as we recurse only at the end of
// the method, we can safely default to true here. The cache is updated at the end of the method
// with the actual comparison result.
SchemaPair sp = new SchemaPair(src, that);
Boolean cacheHit = cache.putIfAbsent(sp, true);
if (cacheHit != null) {
return cacheHit;
}
boolean equals = Objects.equals(src.isOptional(), that.isOptional())
&& Objects.equals(src.version(), that.version())
&& Objects.equals(src.name(), that.name())
&& Objects.equals(src.doc(), that.doc())
&& Objects.equals(src.type(), that.type())
&& Objects.deepEquals(src.defaultValue(), that.defaultValue())
&& Objects.equals(src.parameters(), that.parameters());
switch (src.type()) {
case STRUCT:
equals = equals && fieldListEquals(src.fields(), that.fields(), cache);
break;
case ARRAY:
equals = equals && schemaEquals(src.valueSchema(), that.valueSchema(), cache);
break;
case MAP:
equals = equals
&& schemaEquals(src.valueSchema(), that.valueSchema(), cache)
&& schemaEquals(src.keySchema(), that.keySchema(), cache);
break;
default:
break;
}
cache.put(sp, equals);
return equals;
}