{"record":{"id":"3ea9a6cbe761cfec","repo":"Netflix/Hystrix","slug":"no-fallback-available","errorCode":null,"errorMessage":"No fallback available.","messagePattern":"No fallback available\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommand.java","lineNumber":293,"sourceCode":"     */\n    protected abstract R run() throws Exception;\n\n    /**\n     * If {@link #execute()} or {@link #queue()} fails in any way then this method will be invoked to provide an opportunity to return a fallback response.\n     * <p>\n     * This should do work that does not require network transport to produce.\n     * <p>\n     * In other words, this should be a static or cached result that can immediately be returned upon failure.\n     * <p>\n     * If network traffic is wanted for fallback (such as going to MemCache) then the fallback implementation should invoke another {@link HystrixCommand} instance that protects against that network\n     * access and possibly has another level of fallback that does not involve network access.\n     * <p>\n     * DEFAULT BEHAVIOR: It throws UnsupportedOperationException.\n     * \n     * @return R or throw UnsupportedOperationException if not implemented\n     */\n    protected R getFallback() {\n        throw new UnsupportedOperationException(\"No fallback available.\");\n    }\n\n    @Override\n    final protected Observable<R> getExecutionObservable() {\n        return Observable.defer(new Func0<Observable<R>>() {\n            @Override\n            public Observable<R> call() {\n                try {\n                    return Observable.just(run());\n                } catch (Throwable ex) {\n                    return Observable.error(ex);\n                }\n            }\n        }).doOnSubscribe(new Action0() {\n            @Override\n            public void call() {\n                // Save thread on which we get subscribed so that we can interrupt it later if needed\n                executionThread.set(Thread.currentThread());","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/Netflix/Hystrix/blob/5ce3bc58c38e7ca60ef2fe0e516e390e294ad941/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommand.java#L275-L311","documentation":"The default HystrixCommand.getFallback() throws UnsupportedOperationException('No fallback available.'); it fires whenever a command fails (exception, timeout, short-circuit, thread-pool rejection, semaphore rejection) and no fallback was overridden. Hystrix then surfaces it as HystrixRuntimeException with FailureType.COMMAND_EXCEPTION / FALLBACK_MISSING semantics.","triggerScenarios":"A command without a getFallback() override fails for any reason: run() throws, execution times out, circuit breaker is open, thread-pool or semaphore rejects, or bad-request exception occurs — and the fallback path is invoked.","commonSituations":"Downstream dependency outage on a command where no one wrote a fallback; timeouts from slow endpoints on commands intended to 'just work'; adding Hystrix to legacy code and observing raw UnsupportedOperationException inside HystrixRuntimeException on first dependency blip.","solutions":["Override getFallback() to return a safe default, cached value, or null","If fallback requires I/O, implement it as another HystrixCommand (with its own fallback) per the Javadoc guidance","If no fallback makes sense, catch HystrixRuntimeException at the call site and degrade the caller's behavior","Tune timeouts/retries on the primary path to reduce frequency of hitting the fallback"],"exampleFix":"// before\npublic class GetUserCommand extends HystrixCommand<User> {\n  protected User run() { return userClient.get(id); } }\n// after\npublic class GetUserCommand extends HystrixCommand<User> {\n  protected User run() { return userClient.get(id); }\n  @Override protected User getFallback() { return User.CACHED_DEFAULT; } }","handlingStrategy":"fallback","validationCode":"null","typeGuard":"// detect a missing fallback before failure (reflection/utility in tests)\n// production guard: override getFallback() in every command, even if it returns null","tryCatchPattern":"catch (HystrixRuntimeException e) { if (\"No fallback available.\".equals(e.getMessage()) || (e.getCause() instanceof UnsupportedOperationException && \"No fallback available.\".equals(e.getCause().getMessage()))) { // degrade caller gracefully } }","preventionTips":["Override getFallback() in every command, even a trivial one returning null","Put any fallback that does I/O behind its own HystrixCommand","Add a code-review/archunit rule that fails commands without a getFallback override"],"tags":["java","hystrix","fallback","resilience"],"backgroundTag":null,"analyzedSha":"5ce3bc58c38e7ca60ef2fe0e516e390e294ad941","analyzedAt":"2026-08-14T10:55:35.600Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}