{"record":{"id":"75a50c58cc33efbb","repo":"flowable/flowable-engine","slug":"post-upgrade-java-delegate-can-t-be-set-when-anoth","errorCode":null,"errorMessage":"Post upgrade java delegate can't be set when another post-upgrade task was already specified.","messagePattern":"Post upgrade java delegate can't be set when another post-upgrade task was already specified\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/migration/ProcessInstanceMigrationDocumentImpl.java","lineNumber":141,"sourceCode":"            if (script != null) {\n                this.postUpgradeScript = script;\n            } else {\n                throw new IllegalArgumentException(\"Post upgrade script can't be null.\");\n            }\n        } else {\n            throw new IllegalArgumentException(\"Post upgrade script can't be set when another post-upgrade task was already specified.\");\n        }\n    }\n\n    public void setPostUpgradeJavaDelegate(String javaDelegateClassName) {\n        if (this.postUpgradeScript == null && this.postUpgradeJavaDelegateExpression == null) {\n            if (StringUtils.isNotEmpty(javaDelegateClassName)) {\n                this.postUpgradeJavaDelegate = javaDelegateClassName;\n            } else {\n                throw new IllegalArgumentException(\"Post upgrade java delegate can't be empty or null.\");\n            }\n        } else {\n            throw new IllegalArgumentException(\"Post upgrade java delegate can't be set when another post-upgrade task was already specified.\");\n        }\n    }\n\n    public void setPostUpgradeJavaDelegateExpression(String expression) {\n        if (this.postUpgradeScript == null && this.postUpgradeJavaDelegate == null) {\n            if (StringUtils.isNotEmpty(expression)) {\n                this.postUpgradeJavaDelegateExpression = expression;\n            } else {\n                throw new IllegalArgumentException(\"Post upgrade expression can't be empty or null.\");\n            }\n        } else {\n            throw new IllegalArgumentException(\"Post upgrade expression can't be set when another post-upgrade task was already specified.\");\n        }\n    }\n\n    @Override\n    public String getMigrateToProcessDefinitionId() {\n        return migrateToProcessDefinitionId;","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/migration/ProcessInstanceMigrationDocumentImpl.java#L123-L159","documentation":"This is the mutual-exclusion counterpart for the Java delegate: if a post-upgrade Script or delegate Expression is already configured, calling setPostUpgradeJavaDelegate throws IllegalArgumentException, because only one post-upgrade task can exist on the migration document.","triggerScenarios":"Calling setPostUpgradeJavaDelegate(className) after setPostUpgradeScript or setPostUpgradeJavaDelegateExpression has already been called on the same ProcessInstanceMigrationDocument.","commonSituations":"Merging migration configuration from multiple sources each specifying a different post-upgrade mechanism; reusing a configured document/builder across runs.","solutions":["Configure exactly one post-upgrade task type per migration document.","Check the getters before calling the setter and skip if a task exists.","Instantiate a new migration document for each migration with distinct settings."],"exampleFix":"// before\ndocument.setPostUpgradeJavaDelegateExpression(\"${fixBean}\");\ndocument.setPostUpgradeJavaDelegate(\"com.acme.FixDelegate\");\n\n// after\ndocument.setPostUpgradeJavaDelegateExpression(\"${fixBean}\"); // single task only","handlingStrategy":"validation","validationCode":"if (document.getPostUpgradeScript() != null || document.getPostUpgradeJavaDelegateExpression() != null) { throw new IllegalStateException(\"post-upgrade task already set\"); }","typeGuard":null,"tryCatchPattern":"try {\n    document.setPostUpgradeJavaDelegate(className);\n} catch (IllegalArgumentException e) {\n    logger.warn(\"Another post-upgrade task already configured\", e);\n}","preventionTips":["Decide on a single post-upgrade strategy per migration","Avoid layering configs that both define post-upgrade tasks","Guard setter calls with getter checks"],"tags":["java","flowable","conflict","validation"],"backgroundTag":"conflicting-config-options","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"}