{"record":{"id":"cd86f2ac3414da07","repo":"Netflix/Hystrix","slug":"fallback-method-wasn-t-found-name-arr","errorCode":null,"errorMessage":"fallback method wasn't found: \" + name + \"(\" + Arrays.toString(fallbackParameterTypes) + \")\"","messagePattern":"fallback method wasn't found: \" \\+ name \\+ \"\\(\" \\+ Arrays\\.toString\\(fallbackParameterTypes\\) \\+ \"\\)\"","errorType":"exception","errorClass":"FallbackDefinitionException","httpStatus":null,"severity":"error","filePath":"hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/utils/MethodProvider.java","lineNumber":190,"sourceCode":"            if (isDefault()) {\n                fallbackParameterTypes = new Class[0];\n            } else {\n                fallbackParameterTypes = commandMethod.getParameterTypes();\n            }\n\n            if (extended && fallbackParameterTypes[fallbackParameterTypes.length - 1] == Throwable.class) {\n                fallbackParameterTypes = ArrayUtils.remove(fallbackParameterTypes, fallbackParameterTypes.length - 1);\n            }\n\n            Class<?>[] extendedFallbackParameterTypes = Arrays.copyOf(fallbackParameterTypes,\n                    fallbackParameterTypes.length + 1);\n            extendedFallbackParameterTypes[fallbackParameterTypes.length] = Throwable.class;\n\n            Optional<Method> exFallbackMethod = getMethod(enclosingType, name, extendedFallbackParameterTypes);\n            Optional<Method> fMethod = getMethod(enclosingType, name, fallbackParameterTypes);\n            Method method = exFallbackMethod.or(fMethod).orNull();\n            if (method == null) {\n                throw new FallbackDefinitionException(\"fallback method wasn't found: \" + name + \"(\" + Arrays.toString(fallbackParameterTypes) + \")\");\n            }\n            return new FallbackMethod(method, exFallbackMethod.isPresent(), isDefault());\n        }\n\n    }\n\n\n    /**\n     * Gets method by name and parameters types using reflection,\n     * if the given type doesn't contain required method then continue applying this method for all super classes up to Object class.\n     *\n     * @param type           the type to search method\n     * @param name           the method name\n     * @param parameterTypes the parameters types\n     * @return Some if method exists otherwise None\n     */\n    public static Optional<Method> getMethod(Class<?> type, String name, Class<?>... parameterTypes) {\n        Method[] methods = type.getDeclaredMethods();","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/Netflix/Hystrix/blob/5ce3bc58c38e7ca60ef2fe0e516e390e294ad941/hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/utils/MethodProvider.java#L172-L208","documentation":"MethodProvider (FallbackMethod.getFallbackMethod) locates the fallback method by name plus parameter types, trying both the plain signature (same params as the command) and the extended signature (params + trailing Throwable). If neither lookup succeeds — including the search up the class hierarchy — it throws FallbackDefinitionException('fallback method wasn't found: name(paramTypes...)') listing the exact signature it searched for.","triggerScenarios":"Declaring @HystrixCommand(fallbackMethod = \"getUserFallback\") but the method does not exist, has a misspelled name, has a different parameter list (extra param not Throwable, different order/types), is private in another class, or the Throwable overload has the exception parameter in a non-trailing position.","commonSituations":"Renaming the fallback method without updating fallbackMethod; adding a parameter to the command method but not the fallback; fallback defined in a parent class with different visibility; overloading fallbacks and expecting Javanica to pick by best match (it requires an exact match).","solutions":["Copy the exact expected signature from the error message and implement the fallback with exactly those parameter types (optionally plus a trailing Throwable)","Verify the method name string in fallbackMethod matches character-for-character (it is not validated at compile time)","Keep the fallback in the same class (or an ancestor) with sufficient visibility and matching static-ness","Add a CI test that invokes each command once so missing fallbacks fail the build, not production"],"exampleFix":"// before\n@HystrixCommand(fallbackMethod = \"getUserFallback\")\npublic User getUser(String id, boolean cached) { ... }\n\nprivate User getUserFallback(String id) { ... }\n\n// after\n@HystrixCommand(fallbackMethod = \"getUserFallback\")\npublic User getUser(String id, boolean cached) { ... }\n\nprivate User getUserFallback(String id, boolean cached, Throwable e) { ... }","handlingStrategy":"validation","validationCode":"String name = ann.fallbackMethod();\nboolean found = false;\nfor (Method fm : clazz.getDeclaredMethods()) {\n  if (!fm.getName().equals(name)) continue;\n  Class<?>[] fp = fm.getParameterTypes();\n  boolean plain = Arrays.equals(fp, commandMethod.getParameterTypes());\n  boolean extended = Arrays.equals(\n      Arrays.copyOf(fp, fp.length - 1), commandMethod.getParameterTypes())\n      && fp[fp.length - 1] == Throwable.class;\n  found |= plain || extended;\n}\nif (!found) throw new IllegalStateException(\"Missing/incorrect fallback: \" + name);","typeGuard":null,"tryCatchPattern":"catch (FallbackDefinitionException e) { log.error(\"{}\", e.getMessage()); /* message shows exact expected signature — implement it */ }","preventionTips":["Update fallbackMethod strings and signatures in the same change as the command method","Keep fallback params identical to command params, optionally + trailing Throwable","Add a reflection scan at startup asserting every declared fallbackMethod resolves"],"tags":["hystrix","javanica","fallback","reflection","method-resolution"],"backgroundTag":null,"analyzedSha":"5ce3bc58c38e7ca60ef2fe0e516e390e294ad941","analyzedAt":"2026-08-14T10:55:35.600Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}