Skip to content

Commit

Permalink
Register superinterfaces of SmallRye FT annotated beans
Browse files Browse the repository at this point in the history
  • Loading branch information
zakkak committed Aug 2, 2024
1 parent 39090e8 commit f528418
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,16 +245,28 @@ void processFallbackMethodsAndClases(BeanArchiveIndexBuildItem beanArchiveIndexB
// Scan both the hierarchy of the declaring class and its interfaces like in
// io.smallrye.faulttolerance.internal.SecurityActions.findDeclaredMethodNames
DotName name = clazz.name();
boolean isBean = beanArchiveIndexBuildItem.getGeneratedClassNames().contains(name);
while (name != null && !DotNames.OBJECT.equals(name)) {
Set<String> methods = classesToScan.computeIfAbsent(name, k -> new HashSet<>());
methods.add(fallbackMethod);

if (isBean) {
// The target class is a generated bean, so SmallRye FT is expected to scan its superinterfaces as well
clazz.interfaceNames()
.forEach(it -> classesToScan.computeIfAbsent(it, k -> new HashSet<>()).add(fallbackMethod));
}

ClassInfo classInfo = index.getClassByName(name);
if (classInfo == null) {
break;
}
name = classInfo.superName();
}
clazz.interfaceNames().forEach(it -> classesToScan.computeIfAbsent(it, k -> new HashSet<>()).add(fallbackMethod));
if (!isBean) {
// If the target class is not a generated bean SmallRye FT is still expected to scan the interfaces implemented by it
clazz.interfaceNames()
.forEach(it -> classesToScan.computeIfAbsent(it, k -> new HashSet<>()).add(fallbackMethod));
}
}

for (Map.Entry<DotName, Set<String>> entry : classesToScan.entrySet()) {
Expand All @@ -266,7 +278,7 @@ void processFallbackMethodsAndClases(BeanArchiveIndexBuildItem beanArchiveIndexB
// interfaces of the bean class and its superclasses through
// io.smallrye.faulttolerance.internal.SecurityActions.findDeclaredMethodNames
if (classInfo.isInterface()) {
// fot interfaces getMethods() is invoked in addition to getDeclaredMethods()
// for interfaces getMethods() is invoked in addition to getDeclaredMethods()
reflectiveClass.produce(ReflectiveClassBuildItem.builder(name.toString()).queryPublicMethods().build());
}
reflectiveClass.produce(ReflectiveClassBuildItem.builder(name.toString()).queryMethods().build());
Expand Down

0 comments on commit f528418

Please sign in to comment.