Pankraz76 commented on code in PR #2425:
URL: https://github.com/apache/maven/pull/2425#discussion_r2125724201


##########
impl/maven-di/src/main/java/org/apache/maven/di/impl/InjectorImpl.java:
##########
@@ -220,7 +220,13 @@ public <Q> Supplier<Q> doGetCompiledBinding(Dependency<Q> 
dep) {
         if (key.getRawType() == List.class) {
             Set<Binding<Object>> res2 = getBindings(key.getTypeParameter(0));
             if (res2 != null) {
-                List<Supplier<Object>> list = 
res2.stream().map(this::compile).collect(Collectors.toList());
+                // Sort bindings by priority (highest first) for deterministic 
ordering
+                List<Binding<Object>> sortedBindings = new ArrayList<>(res2);
+                Comparator<Binding<Object>> comparing = 
Comparator.comparing(Binding::getPriority);
+                sortedBindings.sort(comparing.reversed());

Review Comment:
   ```suggestion
                   sortedBindings.sort(Binding.getPriorityComparator());
   ```
   could shift feature envy in dedicated domain `Binding`.
   
   ```java
   public Comparator<Binding<Object>> getPriorityComparator() {
       return Comparator.comparing(Binding::getPriority);
   }
   ```



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