{"record":{"id":"f77315895a0b1903","repo":"flowable/flowable-engine","slug":"can-t-clear-configuration-beans-f77315","errorCode":null,"errorMessage":"can't clear configuration beans","messagePattern":"can't clear configuration beans","errorType":"exception","errorClass":"ActivitiException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cfg/SpringBeanFactoryProxyMap.java","lineNumber":59,"sourceCode":"\n    @Override\n    public boolean containsKey(Object key) {\n        if ((key == null) || (!String.class.isAssignableFrom(key.getClass()))) {\n            return false;\n        }\n        return beanFactory.containsBean((String) key);\n    }\n\n    @Override\n    public Set<Object> keySet() {\n        throw new ActivitiException(\"unsupported operation on configuration beans\");\n        // List<String> beanNames = Arrays.asList(beanFactory.getBeanDefinitionNames());\n        // return new HashSet<Object>(beanNames);\n    }\n\n    @Override\n    public void clear() {\n        throw new ActivitiException(\"can't clear configuration beans\");\n    }\n\n    @Override\n    public boolean containsValue(Object value) {\n        throw new ActivitiException(\"can't search values in configuration beans\");\n    }\n\n    @Override\n    public Set<Map.Entry<Object, Object>> entrySet() {\n        throw new ActivitiException(\"unsupported operation on configuration beans\");\n    }\n\n    @Override\n    public boolean isEmpty() {\n        throw new ActivitiException(\"unsupported operation on configuration beans\");\n    }\n\n    @Override","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cfg/SpringBeanFactoryProxyMap.java#L41-L77","documentation":"SpringBeanFactoryProxyMap is a read-only view over a Spring BeanFactory; it never holds entries of its own. clear() therefore cannot do anything meaningful and is deliberately unimplemented, throwing ActivitiException.","triggerScenarios":"Calling clear() on the map directly, or via code that clears maps generically (cache eviction, test teardown, Map.clear() invoked by framework cleanup).","commonSituations":"Test cleanup code resetting all maps; a utility that clears any Map it receives; misunderstanding the map as a regular HashMap of configuration beans.","solutions":["Remove the clear() call; the map is a live view of the Spring context and needs no clearing","To remove a bean, manipulate the Spring context (e.g. beanFactory.removeBeanDefinition if a ConfigurableBeanFactory) rather than the map","For tests, recreate the ApplicationContext instead of clearing this map","Wrap the call in an instanceof/check or skip Map instances of this type in generic clearing code"],"exampleFix":"// before\nmap.clear();\n// after\n// no-op: SpringBeanFactoryProxyMap is a read-only view; clear the Spring context instead if needed\n","handlingStrategy":"try-catch","validationCode":"if (map instanceof SpringBeanFactoryProxyMap) {\n    throw new IllegalStateException(\"read-only bean map: clear() is not supported; manage beans via the Spring context\");\n}","typeGuard":"boolean isReadOnlyBeanMap = (map instanceof SpringBeanFactoryProxyMap);","tryCatchPattern":"try {\n    map.clear();\n} catch (ActivitiException e) {\n    // map is a read-only view; reset state elsewhere\n}","preventionTips":["Never call mutation methods (clear/put/remove) on SpringBeanFactoryProxyMap","For resets, recreate the ApplicationContext or manipulate the underlying ConfigurableBeanFactory","Guard generic map-cleanup utilities against this read-only implementation"],"tags":["spring","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-14T05:17:10.506Z"}