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


##########
impl/maven-core/src/main/java/org/apache/maven/project/collector/ProjectsSelector.java:
##########
@@ -37,4 +39,19 @@ public interface ProjectsSelector {
      * @throws ProjectBuildingException In case the POMs are not used.
      */
     List<MavenProject> selectProjects(List<File> files, MavenExecutionRequest 
request) throws ProjectBuildingException;
+
+    /**
+     * Select Maven projects from a list of POM files and report model 
problems encountered while building them.
+     *
+     * @param files List of POM files.
+     * @param request The {@link MavenExecutionRequest}
+     * @param problemConsumer Consumer for model problems encountered while 
building the selected projects.
+     * @return A list of projects that have been found in the specified POM 
files.
+     * @throws ProjectBuildingException In case the POMs are not used.
+     */
+    default List<MavenProject> selectProjects(
+            List<File> files, MavenExecutionRequest request, 
Consumer<ModelProblem> problemConsumer)
+            throws ProjectBuildingException {
+        return selectProjects(files, request);

Review Comment:
   ⚠️ **Silent problem drop for third-party `ProjectsSelector` 
implementations.**
   
   The default body calls `selectProjects(files, request)` — the old 2-arg 
overload — which discards `problemConsumer` entirely. Any `ProjectsSelector` 
implementation that extends the interface but does **not** override the new 
3-arg method will silently swallow all model problems rather than routing them 
to the session collector.
   
   The Javadoc on this method says _"report model problems encountered while 
building them"_, which the default implementation does not do. That's a 
misleading contract.
   
   In practice, Maven's own impls (`DefaultProjectsSelector`) all override the 
method, so the issue is latent today. But the interface is an SPI: embedders 
and plugins that provide custom `ProjectsSelector` implementations won't get 
problems retained without overriding the new method — and they'll get no 
warning that they're silently discarding them.
   
   Consider adding a `@apiNote` Javadoc warning:
   
   ```suggestion
           // NOTE: Implementations that override only the 2-arg 
selectProjects() will silently
           // discard problemConsumer. Override this method to route problems 
to the caller.
           return selectProjects(files, request);
   ```
   
   Or, if the concern is real enough, mark the old 2-arg method `@Deprecated` 
to force implementors to the new overload.



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