{"record":{"id":"cf03f1468290154d","repo":"apache/beam","slug":"unsupportedoperationexception-pcollectionviews","errorCode":null,"errorMessage":"UnsupportedOperationException","messagePattern":"UnsupportedOperationException","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/values/PCollectionViews.java","lineNumber":1234,"sourceCode":"\n        @Override\n        public boolean addAll(Collection<? extends T> c) {\n          throw new UnsupportedOperationException();\n        }\n\n        @Override\n        public boolean addAll(int index, Collection<? extends T> c) {\n          throw new UnsupportedOperationException();\n        }\n\n        @Override\n        public boolean removeAll(Collection<?> c) {\n          throw new UnsupportedOperationException();\n        }\n\n        @Override\n        public boolean retainAll(Collection<?> c) {\n          throw new UnsupportedOperationException();\n        }\n\n        @Override\n        public void clear() {\n          throw new UnsupportedOperationException();\n        }\n\n        @Override\n        public T set(int index, T element) {\n          throw new UnsupportedOperationException();\n        }\n\n        @Override\n        public void add(int index, T element) {\n          throw new UnsupportedOperationException();\n        }\n\n        @Override","sourceCodeStart":1216,"sourceCodeEnd":1252,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/values/PCollectionViews.java#L1216-L1252","documentation":"The List<T> returned by IterableBackedListViewFn (a PCollectionView materialization) is a read-only view; removeAll(Collection) deliberately throws UnsupportedOperationException because side inputs are immutable once materialized.","triggerScenarios":"Calling removeAll(...) on the List obtained from a side input view (e.g. sideInput(PCollectionList view) result) inside a DoFn or user code.","commonSituations":"Treating the side input like a regular ArrayList and trying to bulk-remove elements during pipeline processing; mutating a collection captured from sideInput() inside a ParDo.","solutions":["Copy into a mutable list first: new ArrayList<>(viewedList), then call removeAll.","Reformulate as a filter: build the new list by streaming the view and excluding elements you would remove.","Do the removal on the PCollection itself (e.g. Filter/ParDo) before creating the view."],"exampleFix":"// before\nsideInputList.removeAll(blacklist);\n// after\nList<T> filtered = new ArrayList<>(sideInputList);\nfiltered.removeAll(blacklist);","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"List<T> mutable;\ntry {\n  viewedList.removeAll(toRemove);\n  mutable = viewedList;\n} catch (UnsupportedOperationException e) {\n  mutable = new ArrayList<>(viewedList);\n  mutable.removeAll(toRemove);\n}","preventionTips":["Treat every collection returned from sideInput() as immutable.","Copy into ArrayList before any bulk mutation.","Prefer filtering via streams over in-place removeAll/retainAll."],"tags":["java","apache-beam","immutable-collection","side-input","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}