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


##########
impl/maven-di/src/test/java/org/apache/maven/di/impl/BindingSelectionTest.java:
##########
@@ -120,6 +120,28 @@ void 
rebindingTheSameSupplierDoesNotDuplicateItsProviders() {
         assertEquals(List.of("instance"), injector.getInstance(new 
Key<List<String>>() {}));
     }
 
+    @Test
+    void supplierWithLowerPriorityIsOverriddenByProvidesMethod() {
+        // A binding registered with SESSION_SERVICE_PRIORITY (negative) must 
lose
+        // to a @Provides method at the default priority (0).
+        Injector injector = Injector.create()
+                .bindSupplier(Service.class, DefaultService::new, 
Injector.SESSION_SERVICE_PRIORITY)

Review Comment:
   🐛 **Tautological assertion** — both the low-priority supplier 
(`DefaultService::new`) and `DefaultAndNamed.defaultService()` (`return new 
DefaultService()`) return the same type. 
`assertInstanceOf(DefaultService.class, ...)` passes regardless of which 
binding wins; this test cannot catch a priority-selection bug.
   
   ```suggestion
                   .bindSupplier(Service.class, NamedService::new, 
Injector.SESSION_SERVICE_PRIORITY)
   ```
   
   With `NamedService::new`, if the low-priority supplier incorrectly wins, the 
result is `NamedService` and the assertion fails — making the test actually 
detect priority failures.



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