Skip to content

fix(acl): make the domain classes that s2-create-acl-domains generates compare and serialize as the plugin's - #16968

Merged
borinquenkid merged 1 commit into
7.0.xfrom
fix/acl-generated-domains-equality-7.0.x
Nov 22, 2026
Merged

borinquenkid merged 1 commit into
7.0.xfrom
fix/acl-generated-domains-equality-7.0.x

Conversation

@borinquenkid

Copy link
Copy Markdown
Member

Fixes #15927 (reported by DamsoftDevelopers; a merge to 7.0.x does not close it, so it is closed by hand once the merge-ups land).

The reporter's cause: the domain classes that s2-create-acl-domains copies into an application come from templates, and the templates did not have what the plugin's own domain classes have. AclObjectIdentity had no @EqualsAndHashCode(includes = 'objectId', callSuper = true), so a generated copy compared equal to another with a different objectId: the equality of its base class (AbstractAclObjectIdentity) covers only the class, the parent, the owner and entriesInheriting. The ACL services look ACLs up by that equality, so after a restart a list of more than one object could fail with NotFoundException: Unable to find ACL information for object identity. The other three templates had the same gap: no @EqualsAndHashCode, and none of the four implemented Serializable.

Change: the four templates declare the same @EqualsAndHashCode includes, Serializable and serialVersionUID as the domain classes of the plugin (className; sid and principal; identity, order, sid, mask, granting and the audit flags; objectId with callSuper). Their own toString is kept. s2-create-acl-domains does not overwrite a class that already exists, so the page of the script in the guide now says what to add to a copy generated earlier.

Test: a new GeneratedAclDomainsSpec (the module had no unit tests; it uses the testing support the module already declares) renders each real template, compiles it under another name and checks equality, hashCode and Serializable, including that two identities with different objectId are not equal. All four fail without the change, as run in the repo; with it they pass. CodeNarc and rat are clean. CI is off (no ci).

Not covered: a running application with a generated copy; the spec checks the classes the templates produce, not the script's rendering.

Two of the three reviewers (matrei, codeconsole, jdaugherty), as 7.0.x is released.

https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL

…s compare and serialize as the plugin's

The templates of AclClass, AclSid, AclEntry and AclObjectIdentity had no @EqualsAndHashCode and did not implement
Serializable, unlike the plugin's own domain classes. A generated copy compared by identity, and a generated
AclObjectIdentity compared equal to another with a different objectId, because the equality of its base class ignores
objectId. The ACL services look ACLs up by that equality, so an object whose ACL exists failed with a NotFoundException.

The templates now declare the same equality and serialVersionUID as the domain classes. GeneratedAclDomainsSpec renders each
template, compiles it and checks equality, hashCode and Serializable. The script does not overwrite an existing class, so
the documentation of s2-create-acl-domains says what to add to a copy generated earlier.

Fixes #15927

Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
Copilot AI balanced review requested due to automatic review settings November 13, 2026 03:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@jamesfredley jamesfredley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The generated classes compare and serialize the same way as the plugin's classes. Existing plugin classes are unchanged.

@testlens-app

testlens-app Bot commented Nov 16, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: c49d2e5
▶️ Tests: 49805 executed
⚪️ Checks: 91/91 completed


Learn more about TestLens at testlens.app/docs.

@sbglasius sbglasius left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The four templates now declare the same @EqualsAndHashCode keys, Serializable and serialVersionUID as the plugin's domain classes, so a generated AclObjectIdentity no longer equals one with a different objectId. I ran GeneratedAclDomainsSpec: it passes on this branch, and all four features fail against the 7.0.x templates. The guide note for copies generated before this fix is a good addition, since the script does not overwrite them. Two optional nits inline.

@Issue('#15927')
class GeneratedAclDomainsSpec extends Specification {

private static final String TEMPLATES = 'src/main/templates'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: this path depends on the working directory being the module folder. That is true under Gradle but not always in an IDE run. Passing the folder in as a system property from build.gradle, or finding it relative to the class location, would make it independent of that. Not blocking.

expect:
identity.newInstance(objectId: 2L, aclClass: aclClass) == identity.newInstance(objectId: 2L, aclClass: aclClass)
identity.newInstance(objectId: 2L, aclClass: aclClass).hashCode() == identity.newInstance(objectId: 2L, aclClass: aclClass).hashCode()
identity.newInstance(objectId: 2L, aclClass: aclClass) != identity.newInstance(objectId: 3L, aclClass: aclClass)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Optional: the reported bug was objectId being ignored, and that is covered. One more line, such as two identities with the same objectId but a different aclClass not being equal, would also show that callSuper = true keeps the base-class fields in the comparison.

@borinquenkid

Copy link
Copy Markdown
Member Author

Thanks, Søren. The two nits are tracked in #17132, outside this PR.

@borinquenkid
borinquenkid merged commit d841efd into 7.0.x Nov 22, 2026
92 checks passed
@jdaugherty

Copy link
Copy Markdown
Contributor

@borinquenkid this conflicts with #17114 - please hold off on further contributing changes to the scripts/forge functionality since they're being rewritten

@borinquenkid

Copy link
Copy Markdown
Member Author

Understood

@jdaugherty
jdaugherty deleted the fix/acl-generated-domains-equality-7.0.x branch November 23, 2026 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants