From 573e595bfc40e1460ef394d2a9aae9259f3ac04b Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Thu, 14 Mar 2024 08:46:16 +0200 Subject: [PATCH] Fix misleading error message when REST Client interface has been indexed When a REST Client interface is part of a library or the runtime part of an extension, it's not uncommon to forget to index the module. When that happens, we now provide a proper error message. --- .../reactive/client/impl/ClientProxies.java | 38 +++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/ClientProxies.java b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/ClientProxies.java index 02208bffab490..f7bb2dc7bf51b 100644 --- a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/ClientProxies.java +++ b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/ClientProxies.java @@ -1,5 +1,7 @@ package org.jboss.resteasy.reactive.client.impl; +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; import java.util.Collection; import java.util.List; import java.util.Map; @@ -29,15 +31,45 @@ public T get(Class clazz, WebTarget webTarget, List clazz) { + for (Annotation annotation : clazz.getAnnotations()) { + if (isRestClientAnnotation(annotation)) { + return true; + } + } + for (Method method : clazz.getDeclaredMethods()) { + for (Annotation annotation : method.getDeclaredAnnotations()) { + if (isRestClientAnnotation(annotation)) { + return true; + } + } + } + return false; + } + + private boolean isRestClientAnnotation(Annotation annotation) { + String annClassName = annotation.annotationType().getName(); + if (annClassName.startsWith("jakarta.ws.rs") || annClassName.startsWith( + "org.eclipse.microprofile.rest.client")) { + return true; + } + return false; + } + // for dev console public ClientData getClientData() { return new ClientData(clientProxies.keySet(), failures);