Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent build failure when @Blocking on Application #34570

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import static java.util.stream.Collectors.*;
import static org.jboss.resteasy.reactive.common.processor.EndpointIndexer.CDI_WRAPPER_SUFFIX;
import static org.jboss.resteasy.reactive.common.processor.JandexUtil.isImplementorOf;
import static org.jboss.resteasy.reactive.common.processor.ResteasyReactiveDotNames.APPLICATION;
import static org.jboss.resteasy.reactive.common.processor.ResteasyReactiveDotNames.BLOCKING;
import static org.jboss.resteasy.reactive.common.processor.ResteasyReactiveDotNames.REQUEST_SCOPED;
import static org.jboss.resteasy.reactive.common.processor.scanning.ResteasyReactiveScanner.BUILTIN_HTTP_ANNOTATIONS_TO_METHOD;
Expand Down Expand Up @@ -523,7 +524,7 @@ void addRestClientBeans(Capabilities capabilities,
for (AnnotationInstance registerBlockingClass : registerBlockingClasses) {
AnnotationTarget target = registerBlockingClass.target();
if (target.kind() == AnnotationTarget.Kind.CLASS
&& isImplementorOf(index, target.asClass(), RESPONSE_EXCEPTION_MAPPER)) {
&& isImplementorOf(index, target.asClass(), RESPONSE_EXCEPTION_MAPPER, Set.of(APPLICATION))) {
// Watch for @Blocking annotations in classes that implements ResponseExceptionMapper:
blockingClassNames.add(target.asClass().toString());
} else if (target.kind() == AnnotationTarget.Kind.METHOD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,20 @@ public static boolean isSubclassOf(IndexView index, ClassInfo info, DotName pare
* @throws RuntimeException if one of the superclasses is not indexed.
*/
public static boolean isImplementorOf(IndexView index, ClassInfo info, DotName name) {
return isImplementorOf(index, info, name, Collections.emptySet());
}

/**
* Returns true if the given Jandex ClassInfo is a subclass of or inherits the given <tt>name</tt>.
*
* @param index the index to use to look up super classes.
* @param info the ClassInfo we want to check.
* @param name the name of the superclass or interface we want to find.
* @param additionalIgnoredSuperClasses return false if the class has any of these as a superclass.
* @throws RuntimeException if one of the superclasses is not indexed.
*/
public static boolean isImplementorOf(IndexView index, ClassInfo info, DotName name,
Set<DotName> additionalIgnoredSuperClasses) {
// Check interfaces
List<DotName> interfaceNames = info.interfaceNames();
for (DotName interfaceName : interfaceNames) {
Expand All @@ -382,7 +396,9 @@ public static boolean isImplementorOf(IndexView index, ClassInfo info, DotName n
}

// Check direct hierarchy
if (info.superName().equals(DOTNAME_OBJECT) || info.superName().equals(DOTNAME_RECORD)) {
DotName superDotName = info.superName();
if (superDotName.equals(DOTNAME_OBJECT) || superDotName.equals(DOTNAME_RECORD)
|| additionalIgnoredSuperClasses.contains(superDotName)) {
return false;
}
if (info.superName().equals(name)) {
Expand All @@ -393,10 +409,10 @@ public static boolean isImplementorOf(IndexView index, ClassInfo info, DotName n
Type superType = info.superClassType();
ClassInfo superClass = index.getClassByName(superType.name());
if (superClass == null) {
// this can happens if the parent is not inside the Jandex index
// this can happen if the parent is not inside the Jandex index
throw new RuntimeException("The class " + superType.name() + " is not inside the Jandex index");
}
return isImplementorOf(index, superClass, name);
return isImplementorOf(index, superClass, name, additionalIgnoredSuperClasses);
}

}