{"record":{"id":"737c3cc0526e7c23","repo":"flowable/flowable-engine","slug":"org-flowable-cdi-impl-processvariablemap-size-is","errorCode":null,"errorMessage":"org.flowable.cdi.impl.ProcessVariableMap.size() is not supported.","messagePattern":"org\\.flowable\\.cdi\\.impl\\.ProcessVariableMap\\.size\\(\\) is not supported\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cdi/src/main/java/org/flowable/cdi/impl/ProcessVariableMap.java","lineNumber":62,"sourceCode":"    public Object put(String key, Object value) {\r\n        if (key == null) {\r\n            throw new IllegalArgumentException(\"This map does not support 'null' keys.\");\r\n        }\r\n        Object variableBefore = businessProcess.getVariable(key);\r\n        businessProcess.setVariable(key, value);\r\n        return variableBefore;\r\n    }\r\n\r\n    @Override\r\n    public void putAll(Map<? extends String, ? extends Object> m) {\r\n        for (Map.Entry<? extends String, ? extends Object> newEntry : m.entrySet()) {\r\n            businessProcess.setVariable(newEntry.getKey(), newEntry.getValue());\r\n        }\r\n    }\r\n\r\n    @Override\r\n    public int size() {\r\n        throw new UnsupportedOperationException(ProcessVariableMap.class.getName() + \".size() is not supported.\");\r\n    }\r\n\r\n    @Override\r\n    public boolean isEmpty() {\r\n        throw new UnsupportedOperationException(ProcessVariableMap.class.getName() + \".isEmpty() is not supported.\");\r\n    }\r\n\r\n    @Override\r\n    public boolean containsKey(Object key) {\r\n        throw new UnsupportedOperationException(ProcessVariableMap.class.getName() + \".containsKey() is not supported.\");\r\n    }\r\n\r\n    @Override\r\n    public boolean containsValue(Object value) {\r\n        throw new UnsupportedOperationException(ProcessVariableMap.class.getName() + \".containsValue() is not supported.\");\r\n    }\r\n\r\n    @Override\r","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cdi/src/main/java/org/flowable/cdi/impl/ProcessVariableMap.java#L44-L80","documentation":"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.","triggerScenarios":"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())).","commonSituations":"Unit tests asserting on variable counts via the map; generic Map utility code that calls size() before use; debugging frameworks that dump map contents.","solutions":["Do not use ProcessVariableMap for introspection; use BusinessProcess or the Task/Execution variable query API instead.","Track variable count in your own code if you need it.","Refactor tests to assert on get(name) results rather than size()."],"exampleFix":"// before\nint count = processVariableMap.size();\n\n// after\nboolean hasVar = processVariableMap.get(\"myVar\") != null; // only name-based access is supported","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { count = processVariableMap.size(); } catch (UnsupportedOperationException e) { /* use engine query API instead */ }","preventionTips":["Treat ProcessVariableMap as a keyed accessor only: get/put by name","Use BusinessProcess or engine variable queries for counts","Document at injection points that bulk operations throw"],"tags":["java","cdi","unsupported-operation","map"],"backgroundTag":"unsupported-operation","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"}