Skip to content

Commit

Permalink
Allow use of abstract classes in Quarkus REST in the same way as inte…
Browse files Browse the repository at this point in the history
…rfaces

Fixes: quarkusio#41567
(cherry picked from commit c56532c)
  • Loading branch information
geoand authored and gsmet committed Aug 14, 2024
1 parent 56a41b1 commit 46f4b6b
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,21 @@ public static ResourceScanningResult scanResources(
}
}

// handle abstract classes
scannedResources.values().stream().filter(ClassInfo::isAbstract).forEach(abstractScannedResource -> {
Collection<ClassInfo> allSubclasses = index.getAllKnownSubclasses(abstractScannedResource.name());
if (allSubclasses.size() != 1) {
return; // don't do anything with this case as it's not evident how it's supposed to be handled
}
ClassInfo subclass = allSubclasses.iterator().next();
if (!scannedResources.containsKey(subclass.name())) {
scannedResources.put(subclass.name(), subclass);
scannedResources.remove(abstractScannedResource.name());
scannedResourcePaths.put(subclass.name(), scannedResourcePaths.get(abstractScannedResource.name()));
scannedResourcePaths.remove(abstractScannedResource.name());
}
});

Map<DotName, String> clientInterfaces = new HashMap<>(pathInterfaces);
// for clients it is enough to have @PATH annotations on methods only
for (DotName interfaceName : interfacesWithPathOnMethods) {
Expand Down

0 comments on commit 46f4b6b

Please sign in to comment.