flowable/flowable-engine · error · IllegalArgumentException

collection cannot be null

Error message

collection cannot be null

What it means

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.

Solutions

  1. Initialize the collection variable before rule evaluation, e.g. execution.setVariable('items', new ArrayList<>()) instead of leaving it unset.
  2. Make the DMN expression null-safe: ${items != null && contains(items, allOf(required))}.
  3. Guard the variable producer so it always returns an empty collection, never null.
  4. If the variable comes from JSON input, validate required array fields before starting the DMN evaluation.
  5. Catch IllegalArgumentException around rule evaluation and default the rule to not-hit if the collection is missing.

Example fix

// before
contains(items, allOf(required))   // items is null
// after
items != null && contains(items, allOf(required))
Defensive patterns

Strategy: validation

Validate before calling

if (items == null) throw new IllegalStateException("items must be initialized before DMN evaluation");

Type guard

boolean isNonEmptyCollection(Object c) { return c instanceof Collection<?>; }

Try / catch

try {
    boolean ok = CollectionUtil.allOf(collection, value);
} catch (IllegalArgumentException e) {
    if ("collection cannot be null".equals(e.getMessage())) { /* missing DMN input data */ }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/12c2b3a587f82f78. Report an issue: GitHub.

Appendix: source

Thrown at modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/el/util/CollectionUtil.java:35

import org.flowable.common.engine.impl.util.JsonUtil;
import org.springframework.util.CollectionUtils;

/**
 * @author Yvo Swillens
 */
public class CollectionUtil {

    /**
     * all values of value must be in collection
     *
     * @return {@code true} if all elements of value are within the collection,
     * {@code false} if at least one element of value is not within the collection
     */
    public static boolean allOf(Object collection, Object value) {

        if (collection == null) {
            throw new IllegalArgumentException("collection cannot be null");
        }

        if (value == null) {
            throw new IllegalArgumentException("value cannot be null");
        }

        // collection to check against
        Collection targetCollection = getTargetCollection(collection, value);

        // elements to check
        if (DMNParseUtil.isParseableCollection(value)) {
            Collection valueCollection = DMNParseUtil.parseCollection(value, targetCollection);
            return valueCollection != null && targetCollection.containsAll(valueCollection);
        } else if (DMNParseUtil.isJavaCollection(value)) {
            return targetCollection.containsAll((Collection) value);
        } else if (DMNParseUtil.isArrayNode(value)) {
            Collection valueCollection = DMNParseUtil.getCollectionFromArrayNode(JsonUtil.asFlowableArrayNode(value));
            return valueCollection != null && targetCollection.containsAll(valueCollection);

View on GitHub (pinned to d6d39ce1c6)