{"record":{"id":"dd5d75782afbfd1e","repo":"quarkusio/quarkus","slug":"registerclientcontextresolver-is-only-supported-o-dd5d75","errorCode":null,"errorMessage":"@RegisterClientContextResolver is only supported on static methods of REST Client interfaces that return an object. Offending instance is '${className}#${methodName}'","messagePattern":"@RegisterClientContextResolver is only supported on static methods of REST Client interfaces that return an object\\. Offending instance is '(.+?)#(.+?)'","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/resteasy-reactive/rest-client/deployment/src/main/java/io/quarkus/rest/client/reactive/deployment/ClientContextResolverHandler.java","lineNumber":147,"sourceCode":"                            targetMethodParams.values().toArray(new Expr[0]));\n                    bc.return_(resultHandle);\n                });\n            });\n        });\n\n        return new GeneratedClassResult(restClientInterfaceClassInfo.name().toString(), generatedClassName, priority);\n    }\n\n    private MethodInfo findTargetMethod(AnnotationInstance instance) {\n        MethodInfo targetMethod = null;\n        if (instance.target().kind() == AnnotationTarget.Kind.METHOD) {\n            targetMethod = instance.target().asMethod();\n            if (ignoreAnnotation(targetMethod)) {\n                return null;\n            }\n            if ((targetMethod.flags() & Modifier.STATIC) != 0) {\n                if (targetMethod.returnType().kind() == Type.Kind.VOID) {\n                    throw new IllegalStateException(annotation\n                            + \" is only supported on static methods of REST Client interfaces that return an object.\"\n                            + \" Offending instance is '\" + targetMethod.declaringClass().name().toString() + \"#\"\n                            + targetMethod.name() + \"'\");\n                }\n\n            }\n        }\n\n        return targetMethod;\n    }\n\n    private static Class<?> lookupReturnClass(MethodInfo targetMethod) {\n        Class<?> returnTypeClassName = null;\n        try {\n            returnTypeClassName = Class.forName(targetMethod.returnType().name().toString(), false,\n                    Thread.currentThread().getContextClassLoader());\n        } catch (ClassNotFoundException ignored) {\n","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/resteasy-reactive/rest-client/deployment/src/main/java/io/quarkus/rest/client/reactive/deployment/ClientContextResolverHandler.java#L129-L165","documentation":"When scanning a REST client interface for @RegisterClientContextResolver methods, Quarkus requires the annotated static method to return an object (it is invoked to produce a context resolver instance/value). A void static method cannot supply anything, so the build fails with this IllegalStateException.","triggerScenarios":"Annotating a static void method in a REST client interface with @RegisterClientContextResolver (annotation instance target resolves to a VOID-returning method).","commonSituations":"Method originally used for side-effectful registration refactored to return nothing; developer assumed annotation works like a marker; auto-generated interface where a method was emptied.","solutions":["Give the annotated method a non-void return type matching the expected context resolver type","Remove the @RegisterClientContextResolver annotation if the method is not meant to produce a resolver","Move initialization side effects out of the client interface into an extension build step"],"exampleFix":"// before\n@RegisterClientContextResolver\nstatic void setup() { ... } // void not allowed\n// after\n@RegisterClientContextResolver\nstatic MyResolver setup() { return new MyResolver(); }","handlingStrategy":"validation","validationCode":"if (Modifier.isStatic(m.getModifiers()) && m.getReturnType() == void.class) {\n    throw new IllegalStateException(\"@RegisterClientContextResolver method must not be void\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    handler.findTargetMethod(instance);\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"return an object\")) { /* fix method signature */ }\n    throw e;\n}","preventionTips":["Never annotate void methods with @RegisterClientContextResolver","Ensure annotated methods return the resolver value they are meant to supply","Review interface methods after refactors that changed return types to void"],"tags":["rest-client","annotation-processing","build-time","illegal-state"],"backgroundTag":"rest-client-annotation-misuse","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}