Skip to content

Commit

Permalink
Merge pull request #41606 from geoand/#41567
Browse files Browse the repository at this point in the history
Allow use of abstract classes in Quarkus REST in the same way as interfaces
  • Loading branch information
geoand authored Jul 3, 2024
2 parents f483848 + c56532c commit 229b1c0
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 229b1c0

Please sign in to comment.