{"record":{"id":"0c258c838c771cd5","repo":"Netflix/Hystrix","slug":"failed-executing-wrapped-action0","errorCode":null,"errorMessage":"Failed executing wrapped Action0","messagePattern":"Failed executing wrapped Action0","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hystrix-core/src/main/java/com/netflix/hystrix/strategy/concurrency/HystrixContextSchedulerAction.java","lineNumber":71,"sourceCode":"                    // set the state of this thread to that of its parent\n                    HystrixRequestContext.setContextOnCurrentThread(parentThreadState);\n                    // execute actual Action0 with the state of the parent\n                    actual.call();\n                    return null;\n                } finally {\n                    // restore this thread back to its original state\n                    HystrixRequestContext.setContextOnCurrentThread(existingState);\n                }\n            }\n        });\n    }\n\n    @Override\n    public void call() {\n        try {\n            c.call();\n        } catch (Exception e) {\n            throw new RuntimeException(\"Failed executing wrapped Action0\", e);\n        }\n    }\n\n}\n","sourceCodeStart":53,"sourceCodeEnd":76,"githubUrl":"https://github.com/Netflix/Hystrix/blob/5ce3bc58c38e7ca60ef2fe0e516e390e294ad941/hystrix-core/src/main/java/com/netflix/hystrix/strategy/concurrency/HystrixContextSchedulerAction.java#L53-L76","documentation":"HystrixContextSchedulerAction wraps each Action0 submitted through the Hystrix scheduler so request context can be propagated. Its call() catches any Exception thrown by the wrapped action and rethrows it as this RuntimeException. It is a wrapper around a real failure in user/command code, not a Hystrix defect - always inspect the cause.","triggerScenarios":"The scheduled action (typically command run()/Observable construction, or user code queued via the Hystrix concurrency strategy's scheduler) throws a checked Exception, which RxJava Action0.call() is not declared to throw, so it is wrapped here.","commonSituations":"run() throwing a checked exception (SQLException, IOException) that escapes wrapping logic; NPEs inside command code executing on the pool thread; custom code submitted directly to HystrixContextScheduler without its own error handling.","solutions":["Read the nested cause (getCause()) to find the actual failing code and fix it there.","Ensure command run() translates checked exceptions into HystrixBadRequestException or runtime exceptions deliberately, not accidentally.","Add onError handling on the observable chain (onErrorResumeNext/doOnError) to handle failures from scheduled actions."],"exampleFix":"// before\npublic String run() {\n    return jdbcQuery(sql); // SQLException bubbles out wrapped in RuntimeException\n}\n\n// after\npublic String run() {\n    try { return jdbcQuery(sql); }\n    catch (SQLException e) { throw new RuntimeException(\"query failed\", e); }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    action.call();\n} catch (RuntimeException e) {\n    Throwable root = e.getCause() != null ? e.getCause() : e; // unwrap 'Failed executing wrapped Action0'\n    // handle root cause: business error, bug in run(), etc.\n}","preventionTips":["Always unwrap the cause of this wrapper exception before diagnosing.","Handle all checked exceptions inside run()/action code explicitly."],"tags":["hystrix","rxjava","exception-wrapping","debugging"],"backgroundTag":null,"analyzedSha":"5ce3bc58c38e7ca60ef2fe0e516e390e294ad941","analyzedAt":"2026-08-14T10:55:35.600Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}