Skip to content

Commit

Permalink
Merge pull request #15898 from mkouba/issue-15886
Browse files Browse the repository at this point in the history
ArC - fix the algorithm to find event parameter qualifiers
  • Loading branch information
gastaldi authored Mar 21, 2021
2 parents cbdb719 + 4f83ab7 commit 5d54dc7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Type getDisposedParameterType() {
MethodParameterInfo initDisposedParam(MethodInfo disposerMethod) {
List<MethodParameterInfo> disposedParams = new ArrayList<>();
for (AnnotationInstance annotation : disposerMethod.annotations()) {
if (Kind.METHOD_PARAMETER.equals(annotation.target().kind()) && annotation.name().equals(DotNames.DISPOSES)) {
if (Kind.METHOD_PARAMETER == annotation.target().kind() && annotation.name().equals(DotNames.DISPOSES)) {
disposedParams.add(annotation.target().asMethodParameter());
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package io.quarkus.arc.processor;

import static io.quarkus.arc.processor.Annotations.find;
import static io.quarkus.arc.processor.Annotations.getParameterAnnotations;

import io.quarkus.arc.processor.BuildExtension.BuildContext;
import io.quarkus.arc.processor.ObserverTransformer.ObserverTransformation;
import io.quarkus.arc.processor.ObserverTransformer.TransformationContext;
Expand Down Expand Up @@ -36,9 +39,11 @@ public class ObserverInfo implements InjectionTargetInfo {
static ObserverInfo create(BeanInfo declaringBean, MethodInfo observerMethod, Injection injection, boolean isAsync,
List<ObserverTransformer> transformers, BuildContext buildContext, boolean jtaCapabilities) {
MethodParameterInfo eventParameter = initEventParam(observerMethod, declaringBean.getDeployment());
AnnotationInstance priorityAnnotation = observerMethod.annotation(DotNames.PRIORITY);
AnnotationInstance priorityAnnotation = find(
getParameterAnnotations(declaringBean.getDeployment(), observerMethod, eventParameter.position()),
DotNames.PRIORITY);
Integer priority;
if (priorityAnnotation != null && priorityAnnotation.target().equals(eventParameter)) {
if (priorityAnnotation != null) {
priority = priorityAnnotation.value().asInt();
} else {
priority = ObserverMethod.DEFAULT_PRIORITY;
Expand Down Expand Up @@ -285,10 +290,9 @@ static TransactionPhase initTransactionPhase(boolean isAsync, BeanDeployment bea
static Set<AnnotationInstance> initQualifiers(BeanDeployment beanDeployment, MethodInfo observerMethod,
MethodParameterInfo eventParameter) {
Set<AnnotationInstance> qualifiers = new HashSet<>();
for (AnnotationInstance annotation : beanDeployment.getAnnotations(observerMethod)) {
if (annotation.target().equals(eventParameter)) {
beanDeployment.extractQualifiers(annotation).forEach(qualifiers::add);
}
for (AnnotationInstance annotation : getParameterAnnotations(beanDeployment, observerMethod,
eventParameter.position())) {
beanDeployment.extractQualifiers(annotation).forEach(qualifiers::add);
}
return qualifiers;
}
Expand Down

0 comments on commit 5d54dc7

Please sign in to comment.