{"record":{"id":"3ab9c79c28cebf22","repo":"OpenFeign/feign","slug":"method-s-should-not-be-called-3ab9c7","errorCode":null,"errorMessage":"Method \\\"%s\\\" should not be called","messagePattern":"Method \\\\\"(.+?)\\\\\" should not be called","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"reactive/src/main/java/feign/reactive/ReactiveInvocationHandler.java","lineNumber":53,"sourceCode":"    this.dispatch = dispatch;\n  }\n\n  @Override\n  public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {\n    if (\"equals\".equals(method.getName())) {\n      try {\n        Object otherHandler =\n            args.length > 0 && args[0] != null ? Proxy.getInvocationHandler(args[0]) : null;\n        return equals(otherHandler);\n      } catch (IllegalArgumentException e) {\n        return false;\n      }\n    } else if (\"hashCode\".equals(method.getName())) {\n      return hashCode();\n    } else if (\"toString\".equals(method.getName())) {\n      return toString();\n    } else if (!dispatch.containsKey(method)) {\n      throw new UnsupportedOperationException(\n          String.format(\"Method \\\"%s\\\" should not be called\", method.getName()));\n    }\n    return this.invoke(method, this.dispatch.get(method), args);\n  }\n\n  @Override\n  public int hashCode() {\n    return this.target.hashCode();\n  }\n\n  @Override\n  public boolean equals(Object obj) {\n    if (obj == null) {\n      return false;\n    }\n    if (obj == this) {\n      return true;\n    }","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/OpenFeign/feign/blob/e2a1e27560a1e68840c34f031afca88b36096e30/reactive/src/main/java/feign/reactive/ReactiveInvocationHandler.java#L35-L71","documentation":"ReactiveInvocationHandler handles the proxy's Object methods (equals, hashCode, toString) and a fixed dispatch table of interface methods. If the proxy is invoked with a Method that is neither an Object method nor present in the dispatch table, it throws UnsupportedOperationException naming the method, indicating the proxy was reached through an unexpected method surface.","triggerScenarios":"Invoking a default interface method, synthetic bridge, or a method obtained from a different class/interface on the reactive proxy; reflective calls through a Method object that does not match the target interface's declared methods.","commonSituations":"AOP/proxying frameworks (Spring AOP, mocking libs) wrapping the Feign proxy and calling synthetic methods; calling default methods of the interface; Java version differences introducing bridges the dispatch map does not contain.","solutions":["Only call methods declared on the target Feign interface through the proxy; avoid calling interface default methods directly on the proxy","If wrapping the proxy, unwrap to the raw proxy before reflective invocation, or register the method in the InvocationHandlerFactory dispatch table","Use a custom ReactiveInvocationHandler whose dispatch includes default-method handling"],"exampleFix":"// before\nproxy.getClass().getMethod(\"someDefaultMethod\").invoke(proxy); // not in dispatch\n// after\n// call only abstract @RequestLine methods, or implement the default logic outside the proxy\n","handlingStrategy":"type-guard","validationCode":"if (!Arrays.asList(Api.class.getMethods()).contains(method)\n    && !\"equals\".equals(method.getName())\n    && !\"hashCode\".equals(method.getName())\n    && !\"toString\".equals(method.getName()))\n  throw new IllegalStateException(\"Method not part of the Feign interface: \" + method);","typeGuard":"static boolean isCallableOnProxy(java.lang.reflect.Method m, Class<?> api) {\n  return Arrays.asList(api.getMethods()).contains(m);\n}","tryCatchPattern":"try {\n  return proxy.someApiMethod(args);\n} catch (UnsupportedOperationException e) {\n  // a method outside the interface dispatch was invoked; fix the caller, not retry\n}","preventionTips":["Call only interface methods on the proxy; never invoke default methods or synthetic bridges directly","Be careful when wrapping Feign proxies with AOP/mocking frameworks"],"tags":["proxy","invocation-handler","reflective-call"],"backgroundTag":"method-not-implemented","analyzedSha":"e2a1e27560a1e68840c34f031afca88b36096e30","analyzedAt":"2026-09-10T12:37:37.238Z","contentChangedAt":"2026-09-10T12:37:37.238Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}