You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
an "ambigious type resolution" occurs within ArC, with the same synthetic bean showing up twice.
Thus, it is impossible to inject generic Syntetic beans, since with the types argument, it cause ambiguity, and without it, it cannot find an instance.
causes myGenericInterface to be injected with the synthetic bean
Actual behavior
java.lang.RuntimeException:
java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.AmbiguousResolutionException: Ambiguous dependencies for type org.acme.my.ext.MyGenericInterface<java.util.concurrent.atomic.AtomicInteger, java.lang.String> and qualifiers [@Default]
- java member: org.acme.my.ext.test.MyExtTest#myGenericInterface
- declared on CLASS bean [types=[org.acme.my.ext.test.MyExtTest, java.lang.Object], qualifiers=[@Default, @Any], target=org.acme.my.ext.test.MyExtTest]
- available beans:
- SYNTHETIC bean [types=[org.acme.my.ext.MyGenericInterface, org.acme.my.ext.MyGenericInterface<java.util.concurrent.atomic.AtomicInteger, java.lang.String>], qualifiers=[@Default, @Any], target=n/a]
- SYNTHETIC bean [types=[org.acme.my.ext.MyGenericInterface, org.acme.my.ext.MyGenericInterface<java.util.concurrent.atomic.AtomicInteger, java.lang.String>], qualifiers=[@Default, @Any], target=n/a]
at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:1190)
at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:268)
at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:129)
at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:418)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:820)
at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
at java.base/java.lang.Thread.run(Thread.java:829)
at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: javax.enterprise.inject.AmbiguousResolutionException: Ambiguous dependencies for type org.acme.my.ext.MyGenericInterface<java.util.concurrent.atomic.AtomicInteger, java.lang.String> and qualifiers [@Default]
- java member: org.acme.my.ext.test.MyExtTest#myGenericInterface
- declared on CLASS bean [types=[org.acme.my.ext.test.MyExtTest, java.lang.Object], qualifiers=[@Default, @Any], target=org.acme.my.ext.test.MyExtTest]
- available beans:
- SYNTHETIC bean [types=[org.acme.my.ext.MyGenericInterface, org.acme.my.ext.MyGenericInterface<java.util.concurrent.atomic.AtomicInteger, java.lang.String>], qualifiers=[@Default, @Any], target=n/a]
- SYNTHETIC bean [types=[org.acme.my.ext.MyGenericInterface, org.acme.my.ext.MyGenericInterface<java.util.concurrent.atomic.AtomicInteger, java.lang.String>], qualifiers=[@Default, @Any], target=n/a]
at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:576)
at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:470)
at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:256)
... 13 more
Notice MyExtTest writeYourOwnUnitTest fails because myGenericInterface cannot be injected because ambiguous resolution (despite addMyGenericInterface only returing 1 instance of it)
@Christopher-Chianelli thanks for the report! This is very likely a regression introduced by this optimization, i.e. it should work fine in 2.3.0. I'll send a PR shortly.
- BeanDeployment#beansByType - a bean should not be listed multiple
times even if it has multiple types with the same raw name in its set of
bean types
- fix a regression introduced in quarkusio#20470
- resolvesquarkusio#20566
Describe the bug
When a Synthetic bean for a generic type is created like this:
an "ambigious type resolution" occurs within ArC, with the same synthetic bean showing up twice.
Thus, it is impossible to inject generic Syntetic beans, since with the types argument, it cause ambiguity, and without it, it cannot find an instance.
Expected behavior
causes
myGenericInterface
to be injected with the synthetic beanActual behavior
How to Reproduce?
Reproducer: https://github.com/Christopher-Chianelli/issue-reproducer/tree/quarkus-extension-syntetic-bean
Steps to reproduce:
my-ext
mvn clean install
MyExtTest
writeYourOwnUnitTest fails because myGenericInterface cannot be injected because ambiguous resolution (despiteaddMyGenericInterface
only returing 1 instance of it)Output of
uname -a
orver
Linux 5.14.9-200.fc34.x86_64
Output of
java -version
openjdk 11.0.12 2021-07-20
GraalVM version (if different from Java)
No response
Quarkus version or git rev
fffe31b
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Additional information
No response
The text was updated successfully, but these errors were encountered: