-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#302: do not use ReferenceSchema#referredSchema for equals+hashCode #378
base: master
Are you sure you want to change the base?
Conversation
@@ -145,7 +145,6 @@ public boolean equals(Object o) { | |||
return that.canEqual(this) && | |||
Objects.equals(refValue, that.refValue) && | |||
Objects.equals(unprocessedProperties, that.unprocessedProperties) && | |||
Objects.equals(referredSchema, that.referredSchema) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @tmarsteel , do you think we loose anything if we keep this line? So my concern is that, with this change, there can be (rare) cases when two schemas are considered equal when they are not (I mean eg. two references pointing to #
, but this denotes the roots of two different schema documents).
What do you think about keeping this line? I see that it might run into infinite equals()
recursions, but that's probably a very rare case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case of Confluent Schema Registry, we call equals
quite often on schema. So we would prefer the fix above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a very good point. The testcase and my actual cyclic schemas both work with referredSchema
being included in equals.
Hm, this doesn't suffice yet. The |
Okay, so it turns out that equals will always cause a stackoverflow when you call it on equal (but not identical) schemas. I have such a cycle in one of my projects, so keeping
|
@tmarsteel @erosb We would prefer the fix where If a client wants to additionally compare the In other words, we need one method to avoid the |
This solves Issue #302. Not including the referred schema feels right to me since it depends on the schemaLoader. I have no idea whether people rely on referredSchema being in equals+hashCode, though.