-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
area/arcIssue related to ARC (dependency injection)Issue related to ARC (dependency injection)kind/bugSomething isn't workingSomething isn't working
Milestone
Description
Describe the bug
Beans.compareAlternativeBeans always prefers the value of the declaring bean, even if the declaring bean doesn't have an alternative priority and the bean itself does. This leads to an NPE when comparing alternate priorities.
Expected behavior
I expect something like this to work be resolvable (not sure this exactly reproduces.. I'm working on it)
@Dependent
static class NoParentAlternativePriority {
@Produces
@ApplicationScoped
@AlternativePriority(3)
PrioritizedProducerMethodBean bar = new PrioritizedProducerMethodBean();
@Produces
@ApplicationScoped
@AlternativePriority(4)
public PrioritizedProducerMethodBean createBar() {
return new PrioritizedProducerMethodBean();
}
}
Actual behavior
As it happened in my situation, the comparison resulted in an NPE:
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: java.lang.NullPointerException
at io.quarkus.arc.processor.Beans.compareAlternativeBeans(Beans.java:551)
at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
at java.base/java.util.TimSort.sort(TimSort.java:220)
at java.base/java.util.Arrays.sort(Arrays.java:1515)
at java.base/java.util.ArrayList.sort(ArrayList.java:1749)
at io.quarkus.arc.processor.Beans.resolveAmbiguity(Beans.java:523)
at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:475)
at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:420)
at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:224)
at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:130)
at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:291)
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:938)
at io.quarkus.builder.BuildContext.run(BuildContext.java:273)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2027)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1551)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1442)
at java.base/java.lang.Thread.run(Thread.java:834)
at org.jboss.threads.JBossThread.run(JBossThread.java:479)
Will create a PR to fix the problem that includes a reproducing test.
Metadata
Metadata
Assignees
Labels
area/arcIssue related to ARC (dependency injection)Issue related to ARC (dependency injection)kind/bugSomething isn't workingSomething isn't working