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
  • Loading branch information
geoand authored and danielsoro committed Sep 20, 2024
1 parent 9c0816b commit 4324cd0
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 4324cd0

Please sign in to comment.