gnodet opened a new issue, #13752:
URL: https://github.com/apache/maven/issues/13752

   When two bindings are registered for the same `@Named` qualifier and are 
collected into a map, the container fails with the raw JDK `Collectors.toMap` 
message. It doesn't say which bindings conflict.
   
   Example, from an embedder using `ApiRunner.createSession` that also bound 
its own `@Named("legacy") Dispatcher`:
   
   ```
   org.apache.maven.di.DIException: Failed to call method static 
org.apache.maven.api.Session 
org.apache.maven.impl.standalone.ApiRunner.newSession(org.eclipse.aether.RepositorySystem,
 org.apache.maven.api.services.Lookup, 
org.apache.maven.impl.standalone.ApiRunner$LocalRepoProvider)
   ...
   Caused by: java.lang.IllegalStateException: Duplicate key legacy (attempted 
merging values 
org.apache.maven.di.impl.Binding$BindingToConstructor$$Lambda$604/0x00007fc0bc1c0680@19827608
 and 
org.apache.maven.di.impl.Binding$BindingToConstructor$$Lambda$604/0x00007fc0bc1c0680@cc9ef8d)
       at 
java.base/java.util.stream.Collectors.duplicateKeyException(Collectors.java:135)
   ```
   The message shows only the key and the lambdas' default `toString()`. It 
doesn't show the qualifier's type, the declaring class or `@Provides` method of 
each binding, or the injection point being resolved. Users have to debug the 
container to find the clash.
   
   **Trigger**: Maven 4.0.0-rc-7 registers a legacy `Dispatcher` itself. 
Embedders that bound their own (which worked with rc-6) now fail at session 
creation.
   
   **Suggested fix**
   
   Give the `toMap` collector a merge function that throws a descriptive 
`DIException`, for example `Duplicate binding for @Named("legacy") Dispatcher: 
provided by A#method and by B#method`.
   Give `Binding` and its lambdas a `toString()` or origin description that 
includes the declaring class and method.
   


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