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


##########
impl/maven-logging-jul/src/test/java/org/apache/maven/logging/jul/MavenJulHandlerTest.java:
##########
@@ -0,0 +1,189 @@
+/*
+ * 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.jul;
+
+import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+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.logging.impl.DefaultLoggerManager;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+@Timeout(10)
+class MavenJulHandlerTest {
+
+    private DefaultLoggerManager testManager;
+
+    @BeforeEach
+    void installTestManager() {
+        testManager = new DefaultLoggerManager();
+        testManager.setRootLoggerLevel(LogLevel.TRACE);
+        testManager.install();
+    }
+
+    @AfterEach
+    void clearTestManager() {
+        testManager.uninstall();
+        testManager = null;
+    }
+
+    @ParameterizedTest(name = "JUL {0} -> LogLevel.{1}")
+    @CsvSource({
+        "FINEST, TRACE",
+        "FINER, DEBUG",
+        "FINE, DEBUG",
+        "CONFIG, INFO",
+        "INFO, INFO",
+        "WARNING, WARN",
+        "SEVERE, ERROR",
+    })
+    void julLevelMapsToCorrectLogLevel(String julLevelName, String 
expectedLogLevel) {
+        Level julLevel = Level.parse(julLevelName);

Review Comment:
   Fixed — added assertNull assertion to verify the event is silently dropped 
during re-entrant publish.



##########
impl/maven-di/src/main/java/org/apache/maven/di/impl/InjectorImpl.java:
##########
@@ -67,10 +67,16 @@ public class InjectorImpl implements Injector {
     private final Set<String> loadedUrls = new HashSet<>();
     private final ThreadLocal<Set<Key<?>>> resolutionStack = new 
ThreadLocal<>();
 
+    private final Consumer<String> dumpSink;
     private final InjectorDiagnostics diagnostics = new 
InjectorDiagnostics(this, bindings, scopes);
     private int registrationDepth;
 
     public InjectorImpl() {
+        this(System.out::println);

Review Comment:
   By design — the lambda evaluates System.out at call time (not capture time), 
so the embedded invoker System.setOut() redirect works correctly. 
InjectorDiagnostics only writes when maven.di.debug is explicitly set, so no 
output occurs by default.



##########
impl/maven-di/src/main/java/org/apache/maven/di/impl/InjectorImpl.java:
##########
@@ -67,10 +67,16 @@ public class InjectorImpl implements Injector {
     private final Set<String> loadedUrls = new HashSet<>();
     private final ThreadLocal<Set<Key<?>>> resolutionStack = new 
ThreadLocal<>();
 
+    private final Consumer<String> dumpSink;
     private final InjectorDiagnostics diagnostics = new 
InjectorDiagnostics(this, bindings, scopes);
     private int registrationDepth;
 
     public InjectorImpl() {
+        this(System.out::println);

Review Comment:
   By design — the lambda evaluates System.out at call time (not capture time), 
so the embedded invoker System.setOut() redirect works correctly. 
InjectorDiagnostics only writes when maven.di.debug is explicitly set, so no 
output occurs by default.



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