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


##########
maven-core/src/main/java/org/apache/maven/project/ReactorModelPool.java:
##########
@@ -48,13 +49,20 @@ class ReactorModelPool {
      * @throws IllegalStateException if version was null and multiple modules 
share the same groupId + artifactId
      */
     public Model get(String groupId, String artifactId, String version) {
-        return modelsByGa.getOrDefault(new GAKey(groupId, artifactId), 
Collections.emptySet()).stream()
-                .filter(m -> version == null || version.equals(getVersion(m)))
-                .reduce((a, b) -> {
-                    throw new IllegalStateException(
-                            "Multiple modules with key " + a.getGroupId() + 
':' + a.getArtifactId());
-                })
-                .orElse(null);
+        Collection<Model> models = modelsByGa.getOrDefault(new GAKey(groupId, 
artifactId), Collections.emptySet());
+        if (models.isEmpty()) {
+            return null;
+        } else if (models.size() == 1) {
+            return models.iterator().next();
+        } else {
+            return models.stream()
+                    .filter(m -> version == null || 
version.equals(getVersion(m)))
+                    .reduce((a, b) -> {
+                        throw new IllegalStateException(
+                                "Multiple modules with key " + a.getGroupId() 
+ ':' + a.getArtifactId());
+                    })
+                    .orElse(null);
+        }

Review Comment:
   This does not change the behaviour, right ? What's the point ?



-- 
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: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to