{"record":{"id":"6121eab72c60dc1a","repo":"flowable/flowable-engine","slug":"setting-variable-is-not-supported-for-read-only-de-6121ea","errorCode":null,"errorMessage":"Setting variable is not supported for read only delegate execution","messagePattern":"Setting variable is not supported for read only delegate execution","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/delegate/ReadOnlyDelegateExecution.java","lineNumber":120,"sourceCode":"\n    /**\n     * returns whether this execution is a process instance or not.\n     */\n    boolean isProcessInstanceType();\n\n    /**\n     * Returns whether this execution is a scope.\n     */\n    boolean isScope();\n\n    /**\n     * Returns whether this execution is the root of a multi instance execution.\n     */\n    boolean isMultiInstanceRoot();\n\n    @Override\n    default void setVariable(String variableName, Object variableValue) {\n        throw new UnsupportedOperationException(\"Setting variable is not supported for read only delegate execution\");\n    }\n\n    @Override\n    default void setTransientVariable(String variableName, Object variableValue) {\n        throw new UnsupportedOperationException(\"Setting transient variable is not supported for read only delegate execution\");\n    }\n}\n","sourceCodeStart":102,"sourceCodeEnd":128,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/delegate/ReadOnlyDelegateExecution.java#L102-L128","documentation":"ReadOnlyDelegateExecution is a wrapper exposing a DelegateExecution to delegate code without write access. Its default setVariable implementation always throws UnsupportedOperationException because mutating variables through this read-only view is intentionally forbidden.","triggerScenarios":"Calling execution.setVariable(name, value) on a DelegateExecution that is actually a ReadOnlyDelegateExecution — typically from JavaDelegate/delegate code that receives a read-only execution wrapper instead of a mutable one.","commonSituations":"Framework code passing read-only executions to listeners or delegates (e.g. for preview/validation); calling variable writes in a context designed to be side-effect free.","solutions":["Do not call setVariable on read-only executions; capture the value and set it on a mutable execution (e.g. the real DelegateExecution or runtimeService.setVariable)","Check execution instanceof ReadOnlyDelegateExecution before writing","Use execution.setTransientVariable only on writable executions; refactor the delegate to be side-effect free if handed a read-only view"],"exampleFix":"// before\nexecution.setVariable(\"status\", \"done\");\n// after\nif (!(execution instanceof ReadOnlyDelegateExecution)) {\n    execution.setVariable(\"status\", \"done\");\n}","handlingStrategy":"type-guard","validationCode":"boolean writable = !(execution instanceof ReadOnlyDelegateExecution);","typeGuard":"if (execution instanceof ReadOnlyDelegateExecution) { throw new IllegalStateException(\"read-only execution\"); }","tryCatchPattern":"try { execution.setVariable(name, value); } catch (UnsupportedOperationException e) { /* route write to runtimeService or skip */ }","preventionTips":["Check for ReadOnlyDelegateExecution before any variable mutation","Design delegates to accept values as parameters rather than writing variables","Centralize variable writes in one utility that validates writability","Document which execution wrappers are read-only"],"tags":["flowable","variables","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}