{"record":{"id":"eacfa2eb59cf7b71","repo":"ReactiveX/RxJava","slug":"remove-eacfa2","errorCode":null,"errorMessage":"remove","messagePattern":"remove","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"warning","filePath":"src/main/java/io/reactivex/rxjava4/internal/operators/observable/BlockingObservableIterable.java","lineNumber":152,"sourceCode":"\n        @Override\n        public void onComplete() {\n            done = true;\n            signalConsumer();\n        }\n\n        void signalConsumer() {\n            lock.lock();\n            try {\n                condition.signalAll();\n            } finally {\n                lock.unlock();\n            }\n        }\n\n        @Override // otherwise default method which isn't available in Java 7\n        public void remove() {\n            throw new UnsupportedOperationException(\"remove\");\n        }\n\n        @Override\n        public void dispose() {\n            DisposableHelper.dispose(this);\n            signalConsumer(); // Just in case it is currently blocking in hasNext.\n        }\n\n        @Override\n        public boolean isDisposed() {\n            return DisposableHelper.isDisposed(get());\n        }\n    }\n}\n","sourceCodeStart":134,"sourceCodeEnd":167,"githubUrl":"https://github.com/ReactiveX/RxJava/blob/a8ab5356143f37a8f1dd6d76c79191bec5fa343b/src/main/java/io/reactivex/rxjava4/internal/operators/observable/BlockingObservableIterable.java#L134-L167","documentation":"Thrown by the remove() method of the Iterator/Disposable produced by Observable.blockingIterable(). Because the iterable is backed by a streaming Observable (items are produced async and buffered in a queue), there is no backing collection to remove from, so remove() throws UnsupportedOperationException(\"remove\"). The comment notes it overrides a default method for Java 7 compatibility.","triggerScenarios":"Calling it.remove() on the iterator from observable.blockingIterable().iterator(); a generic drain utility that invokes remove(); legacy collection code repurposed onto a blocking iterable.","commonSituations":"Reusing imperative drain code that calls remove() to mark consumption; third-party library that calls remove() on any iterator it owns; forgetting blocking iterables are unmodifiable views.","solutions":["Remove the it.remove() call from your consumption loop; the iterator is read-only.","Collect consumed values into your own list and drop unwanted ones there rather than removing from the iterator.","Filter upstream with Observable.filter(...) before blockingIterable() to exclude items.","If a component requires remove(), delegate through an Iterator whose remove() is a no-op."],"exampleFix":"// before\nIterator<T> it = observable.blockingIterable().iterator();\nwhile (it.hasNext()) { T v = it.next(); if (stale(v)) it.remove(); }\n// after\nList<T> fresh = new ArrayList<>();\nIterator<T> it = observable.blockingIterable().iterator();\nwhile (it.hasNext()) { T v = it.next(); if (!stale(v)) fresh.add(v); }","handlingStrategy":"validation","validationCode":"// Read-only iterator: never call remove().\nIterator<T> it = observable.blockingIterable().iterator();\nwhile (it.hasNext()) {\n    T v = it.next();\n    // process v; it.remove() is unsupported\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat the blockingIterable() iterator as unmodifiable.","Filter upstream with Observable.filter(...) to exclude items.","Collect retained values into your own list instead of mutating the iterator.","Wrap with a no-op remove() forwarder if a dependency requires remove()."],"tags":["rxjava","iterator","unsupported-operation","blocking","observable"],"backgroundTag":null,"analyzedSha":"a8ab5356143f37a8f1dd6d76c79191bec5fa343b","analyzedAt":"2026-08-13T23:25:30.069Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}