Skip to content

Commit

Permalink
Merge pull request quarkusio#21281 from mkouba/issue-21280
Browse files Browse the repository at this point in the history
ArC - fix the warning about interceptors on private methods
  • Loading branch information
geoand authored Nov 9, 2021
2 parents 00e984b + 1645053 commit 3c17fdf
Showing 1 changed file with 23 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,20 @@ static Set<MethodInfo> addInterceptedMethodCandidates(BeanDeployment beanDeploym
List<AnnotationInstance> methodLevelBindings = methodAnnnotations.stream()
.flatMap(a -> beanDeployment.extractInterceptorBindings(a).stream())
.collect(Collectors.toList());
if (Modifier.isPrivate(method.flags())
&& !methodLevelBindings.isEmpty()
&& !Annotations.contains(methodAnnnotations, DotNames.OBSERVES)
&& !Annotations.contains(methodAnnnotations, DotNames.OBSERVES_ASYNC)) {
if (merged.size() == 1) {
LOGGER.warnf("%s will have no effect on method %s.%s() because the method is private",
methodLevelBindings.iterator().next(), classInfo.name(), method.name());
} else {
LOGGER.warnf("Annotations %s will have no effect on method %s.%s() because the method is private",
methodLevelBindings.stream().map(AnnotationInstance::toString).collect(Collectors.joining(",")),
classInfo.name(), method.name());
}

}
merged.addAll(methodLevelBindings);
for (AnnotationInstance classLevelBinding : classLevelBindings) {
if (methodLevelBindings.isEmpty()
Expand All @@ -197,30 +211,18 @@ static Set<MethodInfo> addInterceptedMethodCandidates(BeanDeployment beanDeploym
}
}
if (!merged.isEmpty()) {
if (Modifier.isPrivate(method.flags())) {
if (merged.size() == 1) {
LOGGER.warnf("%s will have no effect on method %s.%s() because the method is private",
merged.iterator().next(), classInfo.name(), method.name());
boolean addToCandidates = true;
if (Modifier.isFinal(method.flags())) {
if (transformUnproxyableClasses) {
methodsFromWhichToRemoveFinal.add(NameAndDescriptor.fromMethodInfo(method));
} else {
LOGGER.warnf("Annotations %s will have no effect on method %s.%s() because the method is private",
merged.stream().map(AnnotationInstance::toString).collect(Collectors.joining(",")),
classInfo.name(), method.name());
}

} else {
boolean addToCandidates = true;
if (Modifier.isFinal(method.flags())) {
if (transformUnproxyableClasses) {
methodsFromWhichToRemoveFinal.add(NameAndDescriptor.fromMethodInfo(method));
} else {
addToCandidates = false;
finalMethodsFoundAndNotChanged.add(method);
}
}
if (addToCandidates) {
candidates.computeIfAbsent(new Methods.MethodKey(method), key -> merged);
addToCandidates = false;
finalMethodsFoundAndNotChanged.add(method);
}
}
if (addToCandidates) {
candidates.computeIfAbsent(new Methods.MethodKey(method), key -> merged);
}
}
}
skipPredicate.methodsProcessed();
Expand Down

0 comments on commit 3c17fdf

Please sign in to comment.