flowable/flowable-engine · error · UnsupportedOperationException

org.flowable.cdi.impl.ProcessVariableMap.size() is not…

Error message

org.flowable.cdi.impl.ProcessVariableMap.size() is not supported.

What it means

ProcessVariableMap deliberately implements only name-based get/put. size() cannot be answered without enumerating all process variables, so the method throws UnsupportedOperationException unconditionally with the fully qualified method name in the message.

Solutions

  1. Do not use ProcessVariableMap for introspection; use BusinessProcess or the Task/Execution variable query API instead.
  2. Track variable count in your own code if you need it.
  3. Refactor tests to assert on get(name) results rather than size().

Example fix

// before
int count = processVariableMap.size();

// after
boolean hasVar = processVariableMap.get("myVar") != null; // only name-based access is supported
Defensive patterns

Strategy: try-catch

Try / catch

try { count = processVariableMap.size(); } catch (UnsupportedOperationException e) { /* use engine query API instead */ }

Prevention

When it happens

Trigger: Any call to size() on the injected map, including indirect calls from code that inspects Map objects (debug logging, Map.toString via entrySet is separate, Spring/CDI tooling, assert statements like assertEquals(0, map.size())).

Common situations: Unit tests asserting on variable counts via the map; generic Map utility code that calls size() before use; debugging frameworks that dump map contents.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at modules/flowable-cdi/src/main/java/org/flowable/cdi/impl/ProcessVariableMap.java:62

    public Object put(String key, Object value) {
        if (key == null) {
            throw new IllegalArgumentException("This map does not support 'null' keys.");
        }
        Object variableBefore = businessProcess.getVariable(key);
        businessProcess.setVariable(key, value);
        return variableBefore;
    }

    @Override
    public void putAll(Map<? extends String, ? extends Object> m) {
        for (Map.Entry<? extends String, ? extends Object> newEntry : m.entrySet()) {
            businessProcess.setVariable(newEntry.getKey(), newEntry.getValue());
        }
    }

    @Override
    public int size() {
        throw new UnsupportedOperationException(ProcessVariableMap.class.getName() + ".size() is not supported.");
    }

    @Override
    public boolean isEmpty() {
        throw new UnsupportedOperationException(ProcessVariableMap.class.getName() + ".isEmpty() is not supported.");
    }

    @Override
    public boolean containsKey(Object key) {
        throw new UnsupportedOperationException(ProcessVariableMap.class.getName() + ".containsKey() is not supported.");
    }

    @Override
    public boolean containsValue(Object value) {
        throw new UnsupportedOperationException(ProcessVariableMap.class.getName() + ".containsValue() is not supported.");
    }

    @Override

View on GitHub (pinned to d6d39ce1c6)