From c56532c0fdfddf96f83c5387d0cec857e908bfe7 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Tue, 2 Jul 2024 13:33:27 +0300 Subject: [PATCH] Allow use of abstract classes in Quarkus REST in the same way as interfaces Fixes: #41567 --- .../scanning/ResteasyReactiveScanner.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/scanning/ResteasyReactiveScanner.java b/independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/scanning/ResteasyReactiveScanner.java index cbb3f8f91dbad..7de89735072ba 100644 --- a/independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/scanning/ResteasyReactiveScanner.java +++ b/independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/scanning/ResteasyReactiveScanner.java @@ -262,6 +262,21 @@ public static ResourceScanningResult scanResources( } } + // handle abstract classes + scannedResources.values().stream().filter(ClassInfo::isAbstract).forEach(abstractScannedResource -> { + Collection 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 clientInterfaces = new HashMap<>(pathInterfaces); // for clients it is enough to have @PATH annotations on methods only for (DotName interfaceName : interfacesWithPathOnMethods) {