{"record":{"id":"46cbfeed50f69dc1","repo":"flowable/flowable-engine","slug":"post-upgrade-java-delegate-can-t-be-empty-or-null","errorCode":null,"errorMessage":"Post upgrade java delegate can't be empty or null.","messagePattern":"Post upgrade java delegate can't be empty or null\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/migration/ProcessInstanceMigrationDocumentImpl.java","lineNumber":138,"sourceCode":"\n    public void setPostUpgradeScript(Script script) {\n        if (this.postUpgradeJavaDelegate == null && this.postUpgradeJavaDelegateExpression == null) {\n            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","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/migration/ProcessInstanceMigrationDocumentImpl.java#L120-L156","documentation":"setPostUpgradeJavaDelegate requires a non-empty class name for the JavaDelegate executed after migration. Flowable throws IllegalArgumentException when the string is null or blank, since a post-upgrade task must be meaningfully specified.","triggerScenarios":"Calling setPostUpgradeJavaDelegate(null) or setPostUpgradeJavaDelegate(\"\") (or whitespace) when no postUpgradeScript or postUpgradeJavaDelegateExpression is yet set on the migration document.","commonSituations":"Reading a class name from properties/env that is missing or empty; refactoring where a constant holding the class name became null; templated migration configs with unfilled placeholders.","solutions":["Pass the fully qualified delegate class name, e.g. \"com.acme.MyPostUpgradeDelegate\".","If no post-upgrade task is needed, omit the call entirely.","Use setPostUpgradeScript or setPostUpgradeJavaDelegateExpression for the other task types."],"exampleFix":"// before\nString delegateClass = properties.getProperty(\"postUpgradeDelegate\"); // null\ndocument.setPostUpgradeJavaDelegate(delegateClass);\n\n// after\nString delegateClass = properties.getProperty(\"postUpgradeDelegate\");\nif (delegateClass != null && !delegateClass.isBlank()) {\n    document.setPostUpgradeJavaDelegate(delegateClass);\n}","handlingStrategy":"validation","validationCode":"if (javaDelegateClassName == null || javaDelegateClassName.isBlank()) { throw new IllegalArgumentException(\"delegate class name required\"); }","typeGuard":"boolean isValidDelegateName(String s) { return s != null && !s.trim().isEmpty(); }","tryCatchPattern":"try {\n    document.setPostUpgradeJavaDelegate(className);\n} catch (IllegalArgumentException e) {\n    logger.error(\"Post-upgrade delegate class name missing\", e);\n}","preventionTips":["Validate config values before feeding them to the migration document","Fail fast at config load time if the delegate property is empty","Set exactly one post-upgrade task kind"],"tags":["java","flowable","validation","empty-string"],"backgroundTag":"empty-required-field","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}