mthmulders commented on a change in pull request #565:
URL: https://github.com/apache/maven/pull/565#discussion_r724474642
##########
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:
I guess this is not thread-safe - multiple threads could run through
this one method at the same time, causing multiple `Logger` instances to be
created. Is that a problem?
##########
File path: maven-plugin-api/src/main/java/org/apache/maven/plugin/Mojo.java
##########
@@ -33,7 +33,11 @@
*/
public interface Mojo
{
- /** The component <code>role</code> hint for Plexus container */
+ /** The component <code>role</code> hint for Plexus container
+ *
+ * @deprecated do not use legacy Plexus API to look up by string.
Review comment:
To be even more helpful for consumers of this API, what *should* they do
instead?
##########
File path: maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
##########
@@ -75,7 +76,8 @@
private boolean parallel;
- private final Map<String, Map<String, Map<String, Object>>>
pluginContextsByProjectAndPluginKey =
+ @SuppressWarnings( "checkstyle:linelength" )
+ private final ConcurrentMap<String, ConcurrentMap<String,
ConcurrentMap<String, Object>>> pluginContextsByProjectAndPluginKey =
Review comment:
There are three `String` occurrences in this line. Maybe a line of doc
saying which `String` holds what value is a good idea. Something like
projectId -> pluginKey -> ??? -> Context
--
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]