Copilot commented on code in PR #160:
URL: 
https://github.com/apache/maven-toolchains-plugin/pull/160#discussion_r3573805261


##########
src/main/java/org/apache/maven/plugins/toolchain/ToolchainsComponentConfigurator.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * 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.plugins.toolchain;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.codehaus.plexus.component.configurator.BasicComponentConfigurator;
+import 
org.codehaus.plexus.component.configurator.converters.ConfigurationConverter;
+
+/**
+ * A configurator for components that handles toolchain requirements specified 
in Maven configuration.
+ * <p>
+ * An instance of {@code ConfigurationConverter} for toolchain requirements
+ * is injected into this configurator, and the required converter is registered
+ * during the instantiation process.
+ */
+@Named("toolchains-requirement-configurator")
+@Singleton
+public class ToolchainsComponentConfigurator extends 
BasicComponentConfigurator {
+
+    @Inject
+    public ToolchainsComponentConfigurator(@Named("ToolchainsRequirement") 
ConfigurationConverter toolchainConverter) {
+        this.converterLookup.registerConverter(toolchainConverter);
+    }
+}

Review Comment:
   `converterLookup` is used in the constructor, but this configurator 
previously depended on a role-hinted `ConverterLookup` (see removed 
`components.xml`). With the current constructor, the inherited 
`converterLookup` may not yet be set by the container and/or may resolve to the 
default/global lookup, which can cause NPEs or change converter scoping. Prefer 
injecting a dedicated, named `ConverterLookup` and assigning it to the 
superclass field.



##########
src/main/java/org/apache/maven/plugins/toolchain/ToolchainConverter.java:
##########
@@ -55,20 +59,13 @@ public Object fromConfiguration(
             Class baseType,
             ClassLoader classLoader,
             ExpressionEvaluator expressionEvaluator,
-            ConfigurationListener listener)
-            throws ComponentConfigurationException {
+            ConfigurationListener listener) {
         ToolchainsRequirement retValue = new ToolchainsRequirement();
-
-        processConfiguration(retValue, configuration, expressionEvaluator);
-
+        processConfiguration(retValue, configuration);
         return retValue;
     }
 
-    private void processConfiguration(
-            ToolchainsRequirement requirement,
-            PlexusConfiguration configuration,
-            ExpressionEvaluator expressionEvaluator)
-            throws ComponentConfigurationException {
+    private void processConfiguration(ToolchainsRequirement requirement, 
PlexusConfiguration configuration) {

Review Comment:
   `ExpressionEvaluator` is provided to allow Maven/Plexus expression 
interpolation (e.g., `${...}`) while converting configuration. The current 
implementation ignores it and reads `param.getValue()` verbatim, which can 
change runtime behavior for users relying on expressions in `<toolchains>` 
requirements.



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