{"record":{"id":"c8f8db7acd440ed5","repo":"elastic/elasticsearch","slug":"classname-does-not-support-putall","errorCode":null,"errorMessage":"${className} does not support putAll()","messagePattern":"(.+?) does not support putAll\\(\\)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"build-tools/src/main/java/org/elasticsearch/gradle/LazyPropertyMap.java","lineNumber":101,"sourceCode":"    public V put(K key, Supplier<V> supplier) {\n        return put(key, supplier, PropertyNormalization.DEFAULT);\n    }\n\n    public V put(K key, Supplier<V> supplier, PropertyNormalization normalization) {\n        assertNotNull(supplier, \"supplier for key '\" + key + \"'\");\n        PropertyMapEntry<K, V> previous = delegate.put(key, new PropertyMapEntry<>(key, supplier, normalization));\n        return previous == null ? null : previous.getValue();\n    }\n\n    @Override\n    public V remove(Object key) {\n        PropertyMapEntry<K, V> previous = delegate.remove(key);\n        return previous == null ? null : previous.getValue();\n    }\n\n    @Override\n    public void putAll(Map<? extends K, ? extends V> m) {\n        throw new UnsupportedOperationException(this.getClass().getName() + \" does not support putAll()\");\n    }\n\n    @Override\n    public void clear() {\n        delegate.clear();\n    }\n\n    @Override\n    public Set<K> keySet() {\n        return delegate.keySet();\n    }\n\n    @Override\n    public Collection<V> values() {\n        return delegate.values().stream().peek(this::validate).map(PropertyMapEntry::getValue).collect(Collectors.toList());\n    }\n\n    @Override","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools/src/main/java/org/elasticsearch/gradle/LazyPropertyMap.java#L83-L119","documentation":"LazyPropertyMap overrides Map.putAll(Map) to throw UnsupportedOperationException even though put() and remove() are supported. putAll accepts a plain Map<K,V> which cannot carry the per-entry Supplier or PropertyNormalization metadata that single-entry put(K, Supplier<V>, PropertyNormalization) supports; allowing it would silently degrade entries to eager/default-normalized values. Iterate and put() individually instead.","triggerScenarios":"Calling .putAll(someMap) on a LazyPropertyMap. Common when constructing config maps from existing Map literals, merging two maps, or using collectors like Collectors.toMap that feed into putAll.","commonSituations":"Migrating `map.putAll(defaults)` from a LinkedHashMap to LazyPropertyMap; Gradle plugin code that merges user config with defaults in bulk; builder patterns that accumulate via putAll.","solutions":["Replace putAll(m) with m.forEach((k, v) -> lazyMap.put(k, v)).","If the source map already has Supplier values, use the put(K, Supplier<V>) overload per entry.","Restructure so defaults are applied before constructing the LazyPropertyMap, not merged after."],"exampleFix":"// before\nlazyMap.putAll(defaults); // UnsupportedOperationException\n// after\ndefaults.forEach((k, v) -> lazyMap.put(k, v));","handlingStrategy":"validation","validationCode":"if (map instanceof LazyPropertyMap) {\n    throw new IllegalStateException(\"putAll() not supported on LazyPropertyMap; use forEach+put\");\n}","typeGuard":"static boolean isLazyPropertyMap(Map<?,?> m) { return m instanceof LazyPropertyMap; }","tryCatchPattern":null,"preventionTips":["Replace putAll(m) with m.forEach((k,v) -> lazyMap.put(k, v)).","Apply defaults before constructing the LazyPropertyMap rather than merging after.","When refactoring from LinkedHashMap, audit every putAll call site."],"tags":["gradle","build-tools","lazy-collection","unsupported-operation"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}