fix(maintenance): fix broken double-checked locking in jobHelper()#35713
Merged
Conversation
) jobHelper() used volatile without synchronized, allowing multiple threads to race through the null check and call CDIUtils.getBean() more than once. Fixed with full DCL pattern; extracted resolveJobHelperBean() to enable unit testing without CDI. Added concurrency and caching unit tests. Refs: #589 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Merged
Contributor
|
Claude finished @dsilvam's task in 2m 52s —— View job dotCMS Backend Review
SummaryAll four specialized sub-agents returned NO_FINDINGS:
The fix correctly applies the canonical double-checked locking pattern (volatile field + synchronized inner block + double null check), and the new |
Contributor
| dotCMS Backend Review: No Critical, High, or Medium severity issues found. Reviewed by four specialized sub-agents (Security, Database/cache, Java standards, REST API) — all returned NO_FINDINGS. The fix correctly applies the canonical double-checked locking pattern (volatile field + synchronized inner block + double null check), and the new MaintenanceResourceJobHelperTest follows Java 11 syntax with JUnit 5 + Mockito. |
dsolistorres
approved these changes
May 14, 2026
gortiz-dotcms
approved these changes
May 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MaintenanceResource.jobHelper()usedvolatilewithout asynchronizedblock — two threads could simultaneously observenull, both callCDIUtils.getBean(), and both assign the fieldprotected resolveJobHelperBean()to enable unit testing without a live CDI containerCyclicBarrier) and single-call cachingTest plan
MaintenanceResourceJobHelperTest#jobHelper_shouldInitializeBeanExactlyOnce_underConcurrentAccess— 20 threads race; verifiesresolveJobHelperBean()called exactly onceMaintenanceResourceJobHelperTest#jobHelper_shouldReturnCachedInstance_onSubsequentCalls— sequential calls return same instance without re-resolvingMaintenanceResourceIntegrationTestshould continue to passFixes: dotCMS/private-issues#589
🤖 Generated with Claude Code
This PR fixes: #589