{"record":{"id":"549d5f3cdab55070","repo":"apache/hadoop","slug":"remove-not-supported","errorCode":null,"errorMessage":"remove not supported.","messagePattern":"remove not supported\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/SortedRanges.java","lineNumber":379,"sourceCode":"        next = range.getEndIndex();\n        \n      }\n    }\n    \n    /**\n     * Get whether all the ranges have been skipped.\n     * @return <code>true</code> if all ranges have been skipped.\n     *         <code>false</code> otherwise.\n     */\n    synchronized boolean skippedAllRanges() {\n      return !rangeIterator.hasNext() && next>range.getEndIndex();\n    }\n    \n    /**\n     * Remove is not supported. Doesn't apply.\n     */\n    public void remove() {\n      throw new UnsupportedOperationException(\"remove not supported.\");\n    }\n    \n  }\n\n}\n","sourceCodeStart":361,"sourceCodeEnd":385,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/SortedRanges.java#L361-L385","documentation":"SortedRanges.SkipRangeIterator walks the ranges of indices to skip; it is a read-only cursor over skip ranges, so mutation is meaningless and remove() always throws UnsupportedOperationException. The iterator is used inside skipping record readers, far from normal Collection iteration.","triggerScenarios":"Calling iterator.remove() on the SkipRangeIterator obtained from SortedRanges.skipRangeIterator(), typically from generic collection plumbing or a custom reader that treats every Iterator as removable.","commonSituations":"Utility methods written against java.util.Iterator that defensively call remove(); porting a reader that previously used a mutable ArrayList iterator.","solutions":["Remove the remove() call — skip ranges are advanced only via next()/hasNext().","If removal semantics are needed, materialize the indices into your own collection first and mutate that copy."],"exampleFix":"// before\nit.next();\nit.remove();\n\n// after\nit.next(); // advance only; removal is not supported","handlingStrategy":"validation","validationCode":"// never call remove() on SkipRangeIterator; advance only\nwhile (skipIt.hasNext()) { long idx = skipIt.next(); /* use idx */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat framework iterators as read-only cursors.","When passing iterators into generic utilities, wrap them in an unmodifiable adapter.","Read the iterator's contract before calling optional operations like remove()."],"tags":["hadoop","mapreduce","iterator","unsupported-operation","skip-bad-records"],"backgroundTag":"unsupported-iterator-remove","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}