cstamas commented on a change in pull request #565:
URL: https://github.com/apache/maven/pull/565#discussion_r725091336



##########
File path: 
maven-core/src/main/java/org/apache/maven/plugin/internal/MojoLog.java
##########
@@ -22,24 +22,35 @@
 import org.apache.maven.plugin.logging.Log;
 import org.slf4j.Logger;
 
+import javax.inject.Provider;
+
 import static java.util.Objects.requireNonNull;
 
 /**
- * @author jdcasey
+ * Mojo {@link Log} implementation that lazily creates {@link Logger} 
instances.
+ *
+ * @since TBD
  */
-public class MojoLogWrapper
+public class MojoLog
     implements Log
 {
-    private final Logger logger;
+    private final Provider<Logger> loggerProvider;
+
+    private volatile Logger logger;
 
-    public MojoLogWrapper( Logger logger )
+    public MojoLog( Provider<Logger> loggerProvider )
     {
-        this.logger = requireNonNull( logger );
+        this.loggerProvider = requireNonNull( loggerProvider );
+        this.logger = null;
     }
 
-    public void debug( CharSequence content )
+    private Logger getLogger()
     {
-        logger.debug( toString( content ) );
+        if ( logger == null )

Review comment:
       added memoizing provider around instead. Still, this call is not 
required to be thread-safe, still better safe then sorry...
   (no, is not a problem, as LoggerFactory itself "memoizes" things, but 
memoizer is needed to be "lazy")




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