Skip to content

Commit

Permalink
ResteasyServerCommonProcessor - fix resource method reflective scanning
Browse files Browse the repository at this point in the history
- do not register the ReflectiveHierarchyBuildItem twice for most
resource methods; first try the BeanArchiveIndexBuildItem and then add
methods only found in the CombinedIndexBuildItem
- resolves quarkusio#10742
  • Loading branch information
mkouba committed Jul 15, 2020
1 parent 672404d commit 6c68dba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
public final class ReflectiveHierarchyBuildItem extends MultiBuildItem {

private final Type type;
private IndexView index;
private final IndexView index;
private final Predicate<DotName> ignorePredicate;
private String source;
private final String source;

public ReflectiveHierarchyBuildItem(Type type) {
this(type, DefaultIgnorePredicate.INSTANCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -740,23 +740,28 @@ private static void registerReflectionForSerialization(BuildProducer<ReflectiveC
// Declare reflection for all the types implicated in the Rest end points (return types and parameters).
// It might be needed for serialization.
for (DotName annotationType : annotations) {
scanMethodParameters(annotationType, reflectiveHierarchy, index);
scanMethodParameters(annotationType, reflectiveHierarchy, beanArchiveIndex);
Set<AnnotationInstance> processedAnnotations = new HashSet<>();
scanMethods(annotationType, reflectiveHierarchy, beanArchiveIndex, processedAnnotations);
scanMethods(annotationType, reflectiveHierarchy, index, processedAnnotations);
}

// In the case of a constraint violation, these elements might be returned as entities and will be serialized
reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, ViolationReport.class.getName()));
reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, ResteasyConstraintViolation.class.getName()));
}

private static void scanMethodParameters(DotName annotationType,
BuildProducer<ReflectiveHierarchyBuildItem> reflectiveHierarchy, IndexView index) {
private static void scanMethods(DotName annotationType,
BuildProducer<ReflectiveHierarchyBuildItem> reflectiveHierarchy, IndexView index,
Set<AnnotationInstance> processedAnnotations) {
Collection<AnnotationInstance> instances = index.getAnnotations(annotationType);
for (AnnotationInstance instance : instances) {
if (instance.target().kind() != Kind.METHOD) {
continue;
}

if (processedAnnotations.contains(instance)) {
continue;
}
processedAnnotations.add(instance);
MethodInfo method = instance.target().asMethod();
String source = method.declaringClass() + "[" + method + "]";

Expand Down

0 comments on commit 6c68dba

Please sign in to comment.