Fix recursive update issue in SmartProjectComparator#10997
Merged
gnodet merged 1 commit intoapache:masterfrom Aug 6, 2025
Merged
Fix recursive update issue in SmartProjectComparator#10997gnodet merged 1 commit intoapache:masterfrom
gnodet merged 1 commit intoapache:masterfrom
Conversation
cstamas
approved these changes
Aug 4, 2025
Fixes apache#10995 The SmartProjectComparator.getProjectWeight() method was using ConcurrentHashMap.computeIfAbsent() in a recursive context, which could lead to IllegalStateException: Recursive update when calculating project weights in complex dependency graphs or concurrent scenarios. Changes: - Replace computeIfAbsent() with explicit get() + putIfAbsent() pattern - Eliminate recursive calls to computeIfAbsent() that violate ConcurrentHashMap's internal constraints - Maintain thread safety using putIfAbsent() for concurrent access - Add comprehensive test case to verify the fix under concurrent load The fix preserves all existing functionality while eliminating the recursive update exception that could occur during parallel builds of large multi-module projects.
4644977 to
f68f1d7
Compare
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.
Description
Fixes #10995 - Resolves
IllegalStateException: Recursive updateinSmartProjectComparatorduring parallel builds of large multi-module projects.Problem
The
SmartProjectComparator.getProjectWeight()method was usingConcurrentHashMap.computeIfAbsent()in a recursive context. WhencalculateWeight()callsgetProjectWeight()for downstream projects, it creates recursivecomputeIfAbsent()calls that violate ConcurrentHashMap's internal constraints, leading to:Solution
computeIfAbsent()with explicitget()+putIfAbsent()patterncomputeIfAbsent()that cause the exceptionputIfAbsent()for concurrent accessChanges
Core Fix
Test Coverage
Testing
✅ Verified with reproducer: Used maven-multiproject-generator (4383 modules, 6568 dependencies)
✅ Concurrent stress test: 50 threads × 1000 iterations - no recursive update exceptions
✅ Functionality preserved: All existing weight calculations work correctly
✅ Thread safety maintained: Safe concurrent access to project weights
Impact
This fix resolves the issue reported in #10995 where users experienced build failures with
IllegalStateException: Recursive updateduring parallel builds of complex Maven projects.Pull Request opened by Augment Code with guidance from the PR author