gnodet commented on code in PR #13832:
URL: https://github.com/apache/maven/pull/13832#discussion_r4548344104


##########
impl/maven-logging-slf4j/src/main/java/org/apache/maven/logging/slf4j/MavenSimpleLogger.java:
##########
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.logging.slf4j;
+
+import java.util.Arrays;
+import java.util.Map;
+
+import org.apache.maven.api.MonotonicClock;
+import org.apache.maven.api.logging.LogLevel;
+import org.apache.maven.api.logging.LogSink;
+import org.apache.maven.api.logging.LoggerManager;
+import org.apache.maven.logging.impl.DefaultLogEvent;
+import org.apache.maven.logging.impl.DefaultLoggerManager;
+import org.slf4j.Marker;
+import org.slf4j.event.Level;
+import org.slf4j.helpers.LegacyAbstractLogger;
+import org.slf4j.spi.LocationAwareLogger;
+
+/**
+ * Thin SLF4J logger that dispatches events to the Maven unified logging API
+ * via {@link LoggerManager}. Level checks are delegated to
+ * {@link DefaultLoggerManager}; formatting is deferred to the {@link LogSink}.
+ *
+ * @since 3.5.0
+ */
+public class MavenSimpleLogger extends LegacyAbstractLogger {
+
+    private static final StackWalker STACK_WALKER = StackWalker.getInstance();
+    final String pluginId;
+    int currentLogLevel = LocationAwareLogger.INFO_INT;

Review Comment:
   Already addressed — currentLogLevel is declared volatile.



##########
impl/maven-logging-slf4j/src/main/java/org/apache/maven/logging/slf4j/MavenSimpleLogger.java:
##########
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.logging.slf4j;
+
+import java.util.Arrays;
+import java.util.Map;
+
+import org.apache.maven.api.MonotonicClock;
+import org.apache.maven.api.logging.LogLevel;
+import org.apache.maven.api.logging.LogSink;
+import org.apache.maven.api.logging.LoggerManager;
+import org.apache.maven.logging.impl.DefaultLogEvent;
+import org.apache.maven.logging.impl.DefaultLoggerManager;
+import org.slf4j.Marker;
+import org.slf4j.event.Level;
+import org.slf4j.helpers.LegacyAbstractLogger;
+import org.slf4j.spi.LocationAwareLogger;
+
+/**
+ * Thin SLF4J logger that dispatches events to the Maven unified logging API
+ * via {@link LoggerManager}. Level checks are delegated to
+ * {@link DefaultLoggerManager}; formatting is deferred to the {@link LogSink}.
+ *
+ * @since 3.5.0
+ */
+public class MavenSimpleLogger extends LegacyAbstractLogger {
+
+    private static final StackWalker STACK_WALKER = StackWalker.getInstance();
+    final String pluginId;
+    int currentLogLevel = LocationAwareLogger.INFO_INT;

Review Comment:
   Already addressed — currentLogLevel is declared volatile.



##########
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:
   Already addressed — the comment no longer references 
MavenSimpleLogger.renderLevel(). It now correctly describes the 
JUL/MavenJulHandler re-entrant path.



-- 
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]

Reply via email to