gnodet-bot commented on code in PR #13695:
URL: https://github.com/apache/maven/pull/13695#discussion_r4366863867


##########
impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/LookupInvokerLoggingTest.java:
##########
@@ -39,15 +41,13 @@ class LookupInvokerLoggingTest {
 
     @BeforeEach
     void setUp() {
-        // Save original system property
         originalSystemProperty = 
System.getProperty(Constants.MAVEN_LOGGER_DEFAULT_LOG_LEVEL);
-        // Clear system property to test configuration file loading
         System.clearProperty(Constants.MAVEN_LOGGER_DEFAULT_LOG_LEVEL);
+        new DefaultLoggerManager();

Review Comment:
   🟠 **Orphaned setup: `new DefaultLoggerManager()` has no effect.**
   
   `DefaultLoggerManager()`'s constructor no longer calls 
`LoggerManager.set(this)` (removed in this PR). The instance created here is 
immediately orphaned — it's never registered as the global manager. Tests still 
pass because `LoggerManager.get()` triggers `ServiceLoader.discover()`, which 
creates a *different* `DefaultLoggerManager`. The setup appears to configure 
state but doesn't.
   
   ```suggestion
           LoggerManager.set(new DefaultLoggerManager());
   ```



##########
impl/maven-logging/src/main/java/org/apache/maven/logging/impl/DefaultLoggerManager.java:
##########
@@ -0,0 +1,325 @@
+/*
+ * 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.impl;
+
+import java.io.InputStream;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.maven.api.Constants;
+import org.apache.maven.api.logging.LogEvent;
+import org.apache.maven.api.logging.LogLevel;
+import org.apache.maven.api.logging.LogSink;
+import org.apache.maven.api.logging.Logger;
+import org.apache.maven.api.logging.LoggerManager;
+
+/**
+ * Default {@link LoggerManager} implementation. Owns:
+ * <ul>
+ *   <li>Per-logger level configuration (loaded from properties files)</li>
+ *   <li>The active {@link LogSink}</li>
+ *   <li>Severity tracking for {@code --fail-on-severity}</li>
+ * </ul>
+ * <p>
+ * This class has no SLF4J dependency. The SLF4J adapter layer creates
+ * an instance and registers it via {@link LoggerManager#set(LoggerManager)}.

Review Comment:
   🟡 **Stale Javadoc: self-registration claim is outdated.**
   
   `DefaultLoggerManager` no longer registers itself in its constructor. The 
Javadoc says "The SLF4J adapter layer creates an instance and registers it via 
`LoggerManager#set(LoggerManager)`" — this was true before this PR. Now there 
are two registration paths: `ServiceLoader` discovery (automatic, classpath and 
module-path) and explicit `LoggerManager.set()` from `MavenLoggerFactory` when 
the SLF4J adapter reuses the ServiceLoader-installed instance.
   
   ```suggestion
    * This class has no SLF4J dependency. It is discovered automatically via
    * {@link java.util.ServiceLoader} when {@link LoggerManager#get()} is first 
called,
    * or it can be installed explicitly via {@link 
LoggerManager#set(LoggerManager)}.
    * The SLF4J adapter layer reuses the ServiceLoader-installed instance when 
available.
   ```



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