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


##########
impl/maven-di/src/main/java/org/apache/maven/di/Injector.java:
##########
@@ -147,6 +155,25 @@ static Injector create() {
     @Nonnull
     <T> Injector bindSupplier(@Nonnull Class<T> cls, @Nonnull Supplier<T> 
supplier);
 
+    /**
+     * Binds a supplier to a class with an explicit priority.
+     * <p>
+     * A lower priority value means the binding will be overridden by any 
binding with a higher priority.
+     * Use a negative priority (e.g. {@code -10}) to register a fallback 
binding that yields to
+     * plugin-provided {@code @Provides} methods (which default to priority 
{@code 0}).
+     *
+     * @param <T> the type of the instance
+     * @param cls the class to bind to
+     * @param supplier the supplier to use for injection
+     * @param priority the binding priority
+     * @return this injector instance for method chaining
+     * @throws NullPointerException if {@code cls} or {@code supplier} is null
+     */

Review Comment:
   ⚠️ **Missing `@implSpec` and `@since` — default body silently ignores 
`priority`**
   
   The Javadoc describes priority semantics ("a lower priority value means the 
binding will be overridden"), but the default body calls `bindSupplier(cls, 
supplier)`, discarding the `priority` argument entirely. Any external 
`Injector` implementation that relies on the default will silently ignore 
priorities — the fix works only because `InjectorImpl` overrides this method.
   
   Add an `@implSpec` note and a `@since` tag:
   
   ```suggestion
       /**
        * Binds a supplier to a class with an explicit priority.
        * <p>
        * A lower priority value means the binding will be overridden by any 
binding with a higher priority.
        * Use a negative priority (e.g. {@code -10}) to register a fallback 
binding that yields to
        * plugin-provided {@code @Provides} methods (which default to priority 
{@code 0}).
        *
        * @implSpec The default implementation ignores {@code priority} for 
backward compatibility
        *     with existing {@code Injector} implementations. Implementors 
SHOULD override this method
        *     to honor the priority parameter.
        * @param <T> the type of the instance
        * @param cls the class to bind to
        * @param supplier the supplier to use for injection
        * @param priority the binding priority
        * @return this injector instance for method chaining
        * @throws NullPointerException if {@code cls} or {@code supplier} is 
null
        * @since 4.2.0
        */
   ```



##########
impl/maven-di/src/main/java/org/apache/maven/di/Injector.java:
##########
@@ -53,6 +53,14 @@
  */
 public interface Injector {
 
+    /**
+     * Priority assigned to session services injected by Maven core into V4 
mojos.
+     * <p>
+     * A negative value ensures that these fallback bindings are overridden by 
any
+     * plugin-provided {@code @Provides} method (which defaults to priority 
{@code 0}).
+     */
+    int SESSION_SERVICE_PRIORITY = -10;

Review Comment:
   **Missing `@since` on `SESSION_SERVICE_PRIORITY`**
   
   The file uses `@since` on existing API members. This new constant should 
follow the same convention.
   
   ```suggestion
       /**
        * Priority assigned to session services injected by Maven core into V4 
mojos.
        * <p>
        * A negative value ensures that these fallback bindings are overridden 
by any
        * plugin-provided {@code @Provides} method (which defaults to priority 
{@code 0}).
        *
        * @since 4.2.0
        */
       int SESSION_SERVICE_PRIORITY = -10;
   ```



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