gnodet-bot commented on code in PR #13832:
URL: https://github.com/apache/maven/pull/13832#discussion_r4531419989
##########
impl/maven-jline/src/main/java/org/apache/maven/jline/JLineMessageBuilderFactory.java:
##########
@@ -136,7 +136,18 @@ private MavenStyleResolver() {
@Override
public AttributedStyle resolve(String spec) {
- return styles.computeIfAbsent(spec, this::doResolve);
+ try {
+ return styles.computeIfAbsent(spec, this::doResolve);
+ } catch (IllegalStateException e) {
+ // ConcurrentHashMap.computeIfAbsent throws
IllegalStateException("Recursive update")
+ // when the same map is re-entered from within a
computeIfAbsent call on the same
+ // thread. This can happen during FastTerminal
initialization: JLine's StyleResolver
+ // logs via JUL, MavenJulHandler routes to SLF4J,
MavenSimpleLogger.renderLevel()
+ // lazily initialises styled level strings by calling style()
→ resolve() here,
+ // re-entering the same computeIfAbsent. Fall back to DEFAULT
for this event;
+ // subsequent calls will hit the populated cache and succeed
normally.
Review Comment:
💡 **Stale comment — `MavenSimpleLogger.renderLevel()` no longer exists.**
This comment references `MavenSimpleLogger.renderLevel()` as the trigger for
the recursive `computeIfAbsent` re-entry. That method was deleted by the same
commit that introduces this guard (`logging: slim down SLF4J adapter`). The new
`MavenSimpleLogger` does not call `style()` at all — it creates a
`DefaultLogEvent` and dispatches directly to the `LogSink`.
The guard itself is still correct (the recursion can still occur if the
active sink renders via JLine's `StyleResolver`), but the comment's explanation
is now inaccurate.
```suggestion
// ConcurrentHashMap.computeIfAbsent throws
IllegalStateException("Recursive update")
// when the same map is re-entered from within a
computeIfAbsent call on the same
// thread. This can happen during FastTerminal
initialization: JLine's StyleResolver
// logs via JUL, MavenJulHandler routes to the active
LogSink,
// and if the sink renders a styled level string it calls
style() → resolve() here,
// re-entering the same computeIfAbsent. Fall back to
DEFAULT for this event;
// subsequent calls will hit the populated cache and succeed
normally.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]