{"record":{"id":"ab7a6f4ce97d17be","repo":"quarkusio/quarkus","slug":"unsupported-restclientproxy-method-method","errorCode":null,"errorMessage":"Unsupported RestClientProxy method: ${method}","messagePattern":"Unsupported RestClientProxy method: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/resteasy-classic/resteasy-client/runtime/src/main/java/io/quarkus/restclient/runtime/QuarkusProxyInvocationHandler.java","lineNumber":272,"sourceCode":"        }\n        interfaces[0] = resourceInterface;\n        final BeanManager beanManager = getBeanManager(resourceInterface);\n        final Object proxy = Proxy.newProxyInstance(resourceInterface.getClassLoader(), interfaces,\n                new QuarkusProxyInvocationHandler(resourceInterface, target, Set.copyOf(providers), client,\n                        beanManager));\n        ClientHeaderProviders.registerForClass(resourceInterface, proxy, beanManager);\n        return proxy;\n    }\n\n    private Object invokeRestClientProxyMethod(final Method method) {\n        switch (method.getName()) {\n            case \"getClient\":\n                return client;\n            case \"close\":\n                close();\n                return null;\n            default:\n                throw new IllegalStateException(\"Unsupported RestClientProxy method: \" + method);\n        }\n    }\n\n    private void close() {\n        if (closed.compareAndSet(false, true)) {\n            if (creationalContext != null) {\n                creationalContext.release();\n            }\n            client.close();\n        }\n    }\n\n    private Type[] getGenericTypes(Class<?> aClass) {\n        Type[] genericInterfaces = aClass.getGenericInterfaces();\n        Type[] genericTypes = NO_TYPES;\n        for (Type genericInterface : genericInterfaces) {\n            if (genericInterface instanceof ParameterizedType) {\n                genericTypes = ((ParameterizedType) genericInterface).getActualTypeArguments();","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/resteasy-classic/resteasy-client/runtime/src/main/java/io/quarkus/restclient/runtime/QuarkusProxyInvocationHandler.java#L254-L290","documentation":"Thrown by invokeRestClientProxyMethod when code calls a method on the REST client proxy that is neither a @Path resource method nor one of the supported RestClientProxy methods (getClient, close, toString, hashCode, equals, etc.). The proxy only implements the interface contract, so unknown methods are rejected.","triggerScenarios":"Casting the proxy to a concrete class and calling non-interface methods; calling an added default/object method not handled by the switch; invoking methods via reflection that don't exist on the client interface or RestClientProxy.","commonSituations":"Wrapping proxies in libraries that add instrumentation methods; calling a method that exists on the impl class but not the interface; misuse of generic proxies in test code.","solutions":["Call only methods declared on the client interface (or RestClientProxy/getClient/close)","Cast the proxy to the actual client interface type, not an implementation class","If you need the underlying client, use the getClient() method exposed by RestClientProxy","Check for wrapper/proxy frameworks that inject extra methods into the interface"],"exampleFix":"// before\nObject proxy = RestClientBuilder.newBuilder().baseUri(uri).build(MyClient.class);\n((MyClientImpl) proxy).someImplOnlyMethod(); // IllegalStateException: Unsupported RestClientProxy method\n// after\nMyClient proxy = RestClientBuilder.newBuilder().baseUri(uri).build(MyClient.class);\nproxy.get(); // only interface methods","handlingStrategy":"type-guard","validationCode":"if (!(proxy instanceof MyClient)) {\n    throw new IllegalArgumentException(\"proxy must implement the client interface\");\n}","typeGuard":"static boolean supportsMethod(Object proxy, String methodName) {\n    return proxy != null && Arrays.stream(proxy.getClass().getMethods())\n        .anyMatch(m -> m.getName().equals(methodName));\n}","tryCatchPattern":"try {\n    return method.invoke(proxy, args);\n} catch (InvocationTargetException e) {\n    if (e.getCause() instanceof IllegalStateException\n            && e.getCause().getMessage().startsWith(\"Unsupported RestClientProxy method\")) {\n        throw new UnsupportedOperationException(\"Call only methods on the client interface\", e);\n    }\n    throw e;\n}","preventionTips":["Always hold proxies as the client interface type, never as impl classes","Only call methods declared on the interface annotated for REST use","Use getClient() via RestClientProxy to reach the underlying JAX-RS Client","Be careful with proxy-wrapping libraries that inject extra methods"],"tags":["rest-client","proxy","reflection","illegal-state"],"backgroundTag":"unsupported-proxy-method","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}