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

Drop properties validation in TenantDescriptor#equals #158

Merged

Conversation

smcvb
Copy link
Member

@smcvb smcvb commented Nov 8, 2023

During a clean-up of this repository I (yes, me) accidentally introduces the propeties to the TenantDescriptor#equals method.
This was, as it turns out, wrong.

The TenantDescriptor is both constructed by the extension it self and by users, both not necessarily knowledgable about the properties, but definitely knowledgable about the right tenantId.
To have the multi-tenancy extension behave as intended, validating the TenantDescriptor based on just it's tenantId is paramount.

As such, this pull request removes properties from the TenantDescriptor#equals method again.
Furthermore, I have added a test case to validate the properties field does not have any influence on the behavior of equals.

Drop validation on the properties in equals. This was accidentally
reintroduced during a boy scouting task throughout the project, but this
 was incorrect. The functionality of the multi-tenancy extension expects
  to match on the tenantId ONLY, as properties may differ wildly during
  the flow of the extension as they can be created by the extensions
  and/or users themselves. In those cases, a automated creation and user
   creation of the TenantDescriptor should simply match on the tenantId
   to provide the desired functionality.

#bug/tenant-descriptor-equals-without-properties
Copy link
Contributor

@schananas schananas left a comment

Choose a reason for hiding this comment

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

Hash function also needs to drop properties return Objects.hash(tenantId, properties);

return Objects.hash(tenantId);

Drop properties from hashCode too

#bug/tenant-descriptor-equals-without-properties
@smcvb
Copy link
Member Author

smcvb commented Nov 8, 2023

Hash function also needs to drop properties return Objects.hash(tenantId, properties);

return Objects.hash(tenantId);

Sharp, and adjusted!

@smcvb smcvb requested a review from schananas November 8, 2023 10:59
Copy link

sonarcloud bot commented Nov 8, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@smcvb smcvb merged commit 594733d into axon-multitenancy-4.9.x Nov 8, 2023
7 checks passed
@smcvb smcvb deleted the bug/tenant-descriptor-equals-without-properties branch November 8, 2023 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants