Skip to content

MCR-3884 fix thread-safety of static caches - #3187

Open
Mewel wants to merge 1 commit into
2025.12.xfrom
issues/MCR-3884-thread-safe-static-caches
Open

Mewel wants to merge 1 commit into
2025.12.xfrom
issues/MCR-3884-thread-safe-static-caches

Conversation

@Mewel

@Mewel Mewel commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Link to jira.

  • MCRRoleManager: keep system roles in an immutable snapshot that is replaced as a whole on reload instead of clearing and refilling shared collections; listSystemRoles() returns an unmodifiable, up-to-date list
  • MCRCategoryDAOImpl: use AtomicLong and ConcurrentHashMap for last modified timestamps; timestamps are now strictly increasing, so changes within the same millisecond are detected by caches
  • MCRLayoutUtilities: cache navigation items per parsed document in a ConcurrentHashMap instead of a global HashMap that was cleared by the refresh thread and could keep items of an outdated navigation.xml; webpage IDs not found in the navigation are no longer stored (they were never served from the cache anyway, but let the map grow unbounded)
  • add tests

Pull Request Checklist (Author)

Please go through the following checklist before assigning the PR for review:

Ticket & Documentation

  • The issue in the ticket is clearly described and the solution is documented.
  • Design decisions (if any) are explained.
  • The ticket references the correct source and target branches.
  • The fixed-version is correctly set in the ticket and matches the PR's target branch (main).

Feature & Improvement Specific Checks

  • Instructions on how to test or use the feature are included or linked (e.g. to documentation).
  • For UI changes: before & after screenshots are attached.
  • New features or migrations are documented.
  • Does this change affect existing applications, data, or configurations?
    • Yes: Is a migration required? If yes, describe it.
    • Breaking change is marked in the commit message.

Bugfix-Specific Checks

  • Affected version is listed in the ticket.
  • Minimal code changes were made (no refactoring).
  • This PR truly fixes only the reported bug.
  • No breaking changes are introduced.
  • A relevant test was added (if feasible).

Testing

  • I have tested the changes locally.
  • The feature behaves as described in the ticket.
  • Were existing tests modified?
    • Yes: explain the changes for reviewers.

MCR Conventions & Metadata

  • MCR naming conventions are followed
  • If the public API has changed:
    • Old API is deprecated or a migration is documented.
    • If not, no action needed.
  • Java license headers are added where necessary.
  • Javadoc is written for non-self-explanatory classes/methods (Clean Code).
  • All configuration options are documented in Javadoc and mycore.properties.
  • No default properties are hardcoded — all set via mycore.properties.

Multi-Repo Considerations

  • Is an equivalent PR in MIR required?
    • If yes, is it already created?

- MCRRoleManager: keep system roles in an immutable snapshot that is
  replaced as a whole on reload instead of clearing and refilling shared
  collections; listSystemRoles() returns an unmodifiable, up-to-date list
- MCRCategoryDAOImpl: use AtomicLong and ConcurrentHashMap for last
  modified timestamps; timestamps are now strictly increasing, so changes
  within the same millisecond are detected by caches
- MCRLayoutUtilities: cache navigation items per parsed document in a
  ConcurrentHashMap instead of a global HashMap that was cleared by the
  refresh thread and could keep items of an outdated navigation.xml;
  webpage IDs not found in the navigation are no longer stored (they were
  never served from the cache anyway, but let the map grow unbounded)
- add tests
@Mewel
Mewel requested a review from yagee-de October 22, 2026 10:26
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.

1 participant