{"record":{"id":"e3a1f333d9be70ef","repo":"apache/iceberg","slug":"does-not-support-setvalue","errorCode":null,"errorMessage":"Does not support setValue.","messagePattern":"Does not support setValue\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/util/StructLikeMap.java","lineNumber":190,"sourceCode":"    public int hashCode() {\n      return inner.hashCode();\n    }\n\n    @Override\n    public boolean equals(Object o) {\n      if (this == o) {\n        return true;\n      } else if (o == null || getClass() != o.getClass()) {\n        return false;\n      }\n\n      StructLikeEntry<?> that = (StructLikeEntry<?>) o;\n      return inner.equals(that.inner);\n    }\n\n    @Override\n    public R setValue(R value) {\n      throw new UnsupportedOperationException(\"Does not support setValue.\");\n    }\n  }\n\n  public <U> StructLikeMap<U> transformValues(Function<T, U> func) {\n    StructLikeMap<U> result = create(type);\n    wrapperMap.forEach((key, value) -> result.put(key.get(), func.apply(value)));\n    return result;\n  }\n}\n","sourceCodeStart":172,"sourceCodeEnd":200,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/util/StructLikeMap.java#L172-L200","documentation":"StructLikeMap exposes its entries as Map.Entry views backed by the key's StructLike wrapper. The entry's setValue is intentionally unsupported because values are stored in an internal wrapper map; mutating through the entry view would bypass the map's invariants, so it always throws UnsupportedOperationException.","triggerScenarios":"Iterating a StructLikeMap's entrySet() and calling entry.setValue(newValue) to update a mapping in place.","commonSituations":"Refactoring code from HashMap to StructLikeMap where an in-place entry mutation loop existed; bulk value updates during iteration.","solutions":["Replace entry.setValue(v) with map.put(entry.getKey(), v)","Use StructLikeMap.transformValues(func) for bulk value transformation","Rebuild the map into a plain Map if entry mutation semantics are required"],"exampleFix":"// before\nfor (Map.Entry<Record, String> e : map.entrySet()) {\n  e.setValue(e.getValue().toUpperCase(Locale.ROOT));\n}\n// after\nStructLikeMap<String> updated = map.transformValues(v -> v.toUpperCase(Locale.ROOT));","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never call setValue on entries from StructLikeMap.entrySet()","Use map.put(key, value) for updates","Use transformValues for bulk value changes","Remember StructLikeMap entries are read-only views"],"tags":["unsupported-operation","map"],"backgroundTag":"unsupported-operation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}