{"record":{"id":"ba73e28139693d65","repo":"apache/cassandra","slug":"unsupportedoperationexception-ba73e2","errorCode":null,"errorMessage":"UnsupportedOperationException","messagePattern":"UnsupportedOperationException","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/concurrent/SEPExecutor.java","lineNumber":293,"sourceCode":"        return addTask(taskFactory.toSubmit(withResources, run, result));\n    }\n\n    @Override\n    public Future<?> submit(WithResources withResources, Runnable run)\n    {\n        return addTask(taskFactory.toSubmit(withResources, run));\n    }\n\n    @Override\n    public <T> Future<T> submit(WithResources withResources, Callable<T> call)\n    {\n        return addTask(taskFactory.toSubmit(withResources, call));\n    }\n\n    @Override\n    public boolean inExecutor()\n    {\n        throw new UnsupportedOperationException();\n    }\n\n    public synchronized void shutdown()\n    {\n        if (shuttingDown)\n            return;\n        shuttingDown = true;\n        pool.executors.remove(this);\n        if (getActiveTaskCount() == 0)\n            shutdown.signalAll();\n\n        // release metrics\n        metrics.release();\n        MBeanWrapper.instance.unregisterMBean(mbeanName);\n    }\n\n    public synchronized List<Runnable> shutdownNow()\n    {","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/concurrent/SEPExecutor.java#L275-L311","documentation":"SEPExecutor.AsynchronousExecutor-style inExecutor() is intentionally not implemented for SEPExecutor: the executor cannot reliably determine whether the current thread belongs to it under its shared-worker model, so the method throws UnsupportedOperationException unconditionally. It is a compile-time-contract stub, not a runtime state failure.","triggerScenarios":"Calling executor.inExecutor() on a SEPExecutor (e.g. code that guards re-entrant submission or asserts 'am I on this executor?'), typically via the ExecutorPlus interface.","commonSituations":"Shared utility code that calls inExecutor() on any ExecutorPlus (works for ThreadPoolExecutorPlus but not SEPExecutor); defensive checks added before calling execute() to avoid nested submission; debugging assertions.","solutions":["Do not call inExecutor() on SEPExecutor; track executor membership yourself (e.g. compare Thread.currentThread() against your own marker, or wrap tasks to set a ThreadLocal)","Guard the call with `if (executor instanceof SEPExecutor)` and take a different path","If the check exists to prevent nested execute(), restructure the code so nested submission is unnecessary","Report/patch the call site to use an API SEPExecutor supports"],"exampleFix":"// before\nif (executor.inExecutor()) { ... } // UnsupportedOperationException\n// after\nif (!(executor instanceof SEPExecutor) && executor.inExecutor()) { ... }","handlingStrategy":"validation","validationCode":"if (executor instanceof SEPExecutor)\n    throw new UnsupportedOperationException(\"SEPExecutor.inExecutor() is unsupported; track membership yourself\");","typeGuard":"static boolean supportsInExecutor(ExecutorPlus e)\n{\n    return !(e instanceof SEPExecutor);\n}","tryCatchPattern":null,"preventionTips":["Never call inExecutor() on SEPExecutor; use a ThreadLocal marker if you need re-entrancy checks","Guard generic ExecutorPlus utilities with instanceof checks","Avoid patterns that need 'am I on this executor' assertions with shared-pool executors","Restructure nested-submission prevention at the call-graph level instead"],"tags":["unsupported-operation","concurrency","executor"],"backgroundTag":"unsupported-operation","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}