Skip to content
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

fix: Check for equality of value instead of equality of instance. #1100

Merged
merged 2 commits into from
Dec 20, 2021

Conversation

michael-simons
Copy link
Contributor

isCustomized returned the wrong value for all instances that have been serialized and read back as they obviously does not point to the default instance.

The solution is to check for equality of the values, not for equality of the instances. This is a minor change in behaviour: A setting that is created with the builder matching the exact same defaults is now considered to be not customized.
This solution has been preferred over a custom readResolve returning the DEFAULT when things match as it would otherwise be able to create an instance that identifies itself as customized but changed to not customized when read back, basically the oppositte of what is fixed here: An instances created as not customized must never be read back as customized.

@@ -59,7 +60,20 @@ public boolean encrypted()

private boolean isCustomized()
{
return this != DEFAULT;
return !(DEFAULT.encrypted() == this.encrypted() && DEFAULT.hasEqualTrustStrategy( this ));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed this is the source of contention across serialization exercises. This change would fix that.

@michael-simons michael-simons requested review from gjmwoods and removed request for injectives December 9, 2021 22:45
isCustomized returned the wrong value for all instances that have been serialized and read back as they obviously does not point to the default instance.

The solution is to check for equality of the values, not for equality of the instances. This is a minor change in behaviour: A setting that is created with the builder matching the exact same defaults is now considered to be not customized.
This solution has been preferred over a custom readResolve returning the DEFAULT when things match as it would otherwise be able to create an instance that identifies itself as customized but changed to not customized when read back, basically the oppositte of what is fixed here: An instances created as not customized must never be read back as customized.
These tests needed to be adapted due to the fact that the previous test did not actually change the default value.
@michael-simons michael-simons force-pushed the issue/secsettings-serialized branch from 916e03b to 0cd6f00 Compare December 20, 2021 13:35
@michael-simons michael-simons merged commit d63e076 into neo4j:5.0 Dec 20, 2021
@michael-simons michael-simons deleted the issue/secsettings-serialized branch December 20, 2021 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants