Skip to content

Conversation

@shivvani-r
Copy link

@shivvani-r shivvani-r commented Dec 4, 2025

Description of what I changed

This PR fixes a caching issue where deleting a Child Role left the Parent Role with a stale reference to the deleted child in its childRoles collection. This caused UI breakages when trying to view the Parent Role immediately after deletion.

I modified UserServiceImpl.purgeRole() to fix a cache incoherency where a parent role retains a stale reference to a deleted child role.

Changes:

  • The Fix: Before purging a child role, the method now iterates through all its parent roles, removes the child from their collections, and saves the parent. This forces the Hibernate cache to update immediately.
  • The Test: Added a regression test purgeRole_shouldUpdateParentRoleCacheWhenChildRoleIsDeleted in UserServiceTest to verify that the parent's child collection is empty after the delete.

Issue I worked on

see https://issues.openmrs.org/browse/TRUNK-6450

Checklist: I completed these to help reviewers :)

  • My IDE is configured to follow the code style of this project.

  • I have added tests to cover my changes.

  • I ran mvn clean package right before creating this pull request and added all formatting changes to my commit.

  • All new and existing tests passed.

  • My pull request is based on the latest changes of the master branch.

@dkayiwa
Copy link
Member

dkayiwa commented Dec 5, 2025

Can you discard the formatting changes?

@shivvani-r
Copy link
Author

shivvani-r commented Dec 5, 2025

@dkayiwa i deleted the commit with the formatting changes.

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.

2 participants