C0urante commented on PR #10566: URL: https://github.com/apache/kafka/pull/10566#issuecomment-1452296446
@urbandan I've given the "tweak" fix (i.e., altering `ConnectSchema::equals` to use interface methods and accept any `Schema` instance during equality checking) a shot locally and, although a small additional change is necessary for `assertEquals(defaultValue, anotherValue)` to pass, there was no infinite loop during `assertEquals(anotherValue, defaultValue)` (which I suspect boiled down to the fact that, eventually, we performed an equality check for two schemas that were referentially equal and thus were able to short-circuit the rest of the `equals` method). My `ConnectSchema::equals` method looked like this: ```java public class ConnectSchema { @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Schema)) return false; Schema schema = (Schema) o; boolean matches = Objects.equals(this.isOptional(), schema.isOptional()) && Objects.equals(this.version(), schema.version()) && Objects.equals(this.name(), schema.name()) && Objects.equals(this.doc(), schema.doc()) && Objects.equals(this.type(), schema.type()) && Objects.equals(this.parameters(), schema.parameters()) && Objects.deepEquals(this.defaultValue(), schema.defaultValue()); if (!matches) return false; switch (type) { case ARRAY: return Objects.equals(this.valueSchema(), schema.valueSchema()); case MAP: return Objects.equals(this.keySchema(), schema.keySchema()) && Objects.equals(this.valueSchema(), schema.valueSchema()); case STRUCT: return Objects.equals(this.fields, schema.fields()); default: return true; } } } ``` And the only additional change that was necessary to make `assertEquals(defaultValue, anotherValue)` pass was implement `SchemaBuilder::equals`: ```java public class SchemaBuilder { @Override public boolean equals(Object o) { return this == o || build().equals(o); } @Override public int hashCode() { return build().hashCode(); } } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org