{"record":{"id":"12c2b3a587f82f78","repo":"flowable/flowable-engine","slug":"collection-cannot-be-null","errorCode":null,"errorMessage":"collection cannot be null","messagePattern":"collection cannot be null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/el/util/CollectionUtil.java","lineNumber":35,"sourceCode":"\nimport org.flowable.common.engine.impl.util.JsonUtil;\nimport org.springframework.util.CollectionUtils;\n\n/**\n * @author Yvo Swillens\n */\npublic class CollectionUtil {\n\n    /**\n     * all values of value must be in collection\n     *\n     * @return {@code true} if all elements of value are within the collection,\n     * {@code false} if at least one element of value is not within the collection\n     */\n    public static boolean allOf(Object collection, Object value) {\n\n        if (collection == null) {\n            throw new IllegalArgumentException(\"collection cannot be null\");\n        }\n\n        if (value == null) {\n            throw new IllegalArgumentException(\"value cannot be null\");\n        }\n\n        // collection to check against\n        Collection targetCollection = getTargetCollection(collection, value);\n\n        // elements to check\n        if (DMNParseUtil.isParseableCollection(value)) {\n            Collection valueCollection = DMNParseUtil.parseCollection(value, targetCollection);\n            return valueCollection != null && targetCollection.containsAll(valueCollection);\n        } else if (DMNParseUtil.isJavaCollection(value)) {\n            return targetCollection.containsAll((Collection) value);\n        } else if (DMNParseUtil.isArrayNode(value)) {\n            Collection valueCollection = DMNParseUtil.getCollectionFromArrayNode(JsonUtil.asFlowableArrayNode(value));\n            return valueCollection != null && targetCollection.containsAll(valueCollection);","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/el/util/CollectionUtil.java#L17-L53","documentation":"CollectionUtil.allOf implements DMN unary-tests like 'contains all of'; it requires the collection being tested (first argument) to be non-null. Flowable throws IllegalArgumentException immediately when the collection is null because an 'all elements in collection' check is meaningless without a target collection. This is a fail-fast precondition, not a stateful failure.","triggerScenarios":"A DMN input entry expression evaluates contains(..., allOf(value)) where the collection operand resolves to null — typically an unset or null list variable passed as the first argument of allOf.","commonSituations":"Process variable holding the list was never initialized before the DMN task; a JSON array field is absent in the payload; EL function extracting a collection returns null for missing keys.","solutions":["Initialize the collection variable before rule evaluation, e.g. execution.setVariable('items', new ArrayList<>()) instead of leaving it unset.","Make the DMN expression null-safe: ${items != null && contains(items, allOf(required))}.","Guard the variable producer so it always returns an empty collection, never null.","If the variable comes from JSON input, validate required array fields before starting the DMN evaluation.","Catch IllegalArgumentException around rule evaluation and default the rule to not-hit if the collection is missing."],"exampleFix":"// before\ncontains(items, allOf(required))   // items is null\n// after\nitems != null && contains(items, allOf(required))","handlingStrategy":"validation","validationCode":"if (items == null) throw new IllegalStateException(\"items must be initialized before DMN evaluation\");","typeGuard":"boolean isNonEmptyCollection(Object c) { return c instanceof Collection<?>; }","tryCatchPattern":"try {\n    boolean ok = CollectionUtil.allOf(collection, value);\n} catch (IllegalArgumentException e) {\n    if (\"collection cannot be null\".equals(e.getMessage())) { /* missing DMN input data */ }\n}","preventionTips":["Initialize collection variables to empty lists, never leave unset.","Use null-safe unary tests (collection != null && ...).","Validate required array fields in payloads before DMN tasks.","Audit decision tables for every collection variable they reference.","Default data-source mappings to empty collections."],"tags":["dmn","collection-util","null-check"],"backgroundTag":"null-argument","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"}