adutra commented on PR #493:
URL: https://github.com/apache/polaris/pull/493#issuecomment-2520032705

   > @adutra I haven't seen this behavior during testing. E.g., the 
`DefaultOAuth2ApiService` and the `DefaultContextResolver` are both named 
"default", but the application doesn't seem to have any problem starting up 
both instances.
   
   I suspect HK2 might not be fully compliant with the spec. From [CDI spec 
4.0](https://jakarta.ee/specifications/cdi/4.0/jakarta-cdi-spec-4.0.html#ambig_names):
   
   > An ambiguous name exists when a name resolves to multiple beans. When an 
ambiguous name exists, the container attempts to resolve the ambiguity.
   
   So in our case, if both `DefaultOAuth2ApiService` and 
`DefaultContextResolver` are named `default`, and are both eligible for 
injection, then that should result in an unresolvable ambiguous bean situation.
   
   For example with Quarkus, if I declare the following beans:
   
   ```java
   @Singleton @Named("foo")
   public class Foo1 {}
   
   @Singleton @Named("foo")
   public class Foo2 {}
   ```
   
   I get a deployment error when the app starts (even if the beans aren't 
injected anywhere):
   
   ```
   java.lang.RuntimeException: io.quarkus.builder.BuildException: Build 
failure: Build failed due to errors
        [error]: Build step 
io.quarkus.arc.deployment.ArcProcessor#generateResources threw an exception: 
jakarta.enterprise.inject.spi.DeploymentException: Unresolvable ambiguous bean 
name detected: foo
   Beans:
   CLASS bean [types=[org.apache.polaris.service.catalog.Foo1, 
java.lang.Object], qualifiers=[@Default, @Any, @Named("foo")], 
target=org.apache.polaris.service.catalog.Foo1]
   CLASS bean [types=[org.apache.polaris.service.catalog.Foo2, 
java.lang.Object], qualifiers=[@Default, @Any, @Named("foo")], 
target=org.apache.polaris.service.catalog.Foo2]
   ```
   
   To get past this issue, I would suggest that we copy [SmallRye's 
`@Identifier`](https://github.com/smallrye/smallrye-common/blob/main/annotation/src/main/java/io/smallrye/common/annotation/Identifier.java)
 into our code base.


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