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 committed Jul 2, 2024
1 parent 6a16336 commit ee756d6
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,23 @@ public static ResourceScanningResult scanResources(
}
}

// handle abstract classes
Set<ClassInfo> abstractScannedResources = scannedResources.values().stream().filter(ClassInfo::isAbstract)
.collect(Collectors.toSet());
for (ClassInfo abstractScannedResource : abstractScannedResources) {
Collection<ClassInfo> allSubclasses = index.getAllKnownSubclasses(abstractScannedResource.name());
if (allSubclasses.size() != 1) {
continue; // 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 ee756d6

Please sign in to comment.