{"record":{"id":"25db9c3e7771d515","repo":"apache/hadoop","slug":"not-implemented-25db9c","errorCode":null,"errorMessage":"not implemented","messagePattern":"not implemented","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/Task.java","lineNumber":1637,"sourceCode":"\n    public boolean hasNext() { return hasNext; }\n\n    private int ctr = 0;\n    public VALUE next() {\n      if (!hasNext) {\n        throw new NoSuchElementException(\"iterate past last value\");\n      }\n      try {\n        readNextValue();\n        readNextKey();\n      } catch (IOException ie) {\n        throw new RuntimeException(\"problem advancing post rec#\"+ctr, ie);\n      }\n      reporter.progress();\n      return value;\n    }\n\n    public void remove() { throw new RuntimeException(\"not implemented\"); }\n\n    /// Auxiliary methods\n\n    /** Start processing next unique key. */\n    public void nextKey() throws IOException {\n      // read until we find a new key\n      while (hasNext) { \n        readNextKey();\n      }\n      ++ctr;\n      \n      // move the next key to the current one\n      KEY tmpKey = key;\n      key = nextKey;\n      nextKey = tmpKey;\n      hasNext = more;\n    }\n","sourceCodeStart":1619,"sourceCodeEnd":1655,"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/Task.java#L1619-L1655","documentation":"The value iterator handed to the old-API reduce() does not implement remove(); calling it throws this RuntimeException ('not implemented'). The iterator is a live cursor over the sorted merge stream, so element removal has no meaningful semantics. This mirrors the standard JDK practice of unsupported optional Iterator operations, but with RuntimeException rather than UnsupportedOperationException.","triggerScenarios":"User reduce code or a collection-adapting utility calls remove() on the values iterator inside reduce(); generic algorithms (filter/transform helpers) written against java.util.Iterator that prune as they go.","commonSituations":"Porting in-memory reduce-side aggregation code that mutated the source list; passing the iterator into libraries that may call remove().","solutions":["Delete the remove() call — collect surviving values into your own list if you need to prune.","Wrap the iterator in a read-only adapter before passing it to third-party code that might mutate."],"exampleFix":"// before\nIterator<VALUE> it = values.iterator();\nit.next();\nit.remove();\n\n// after\nList<VALUE> kept = new ArrayList<>();\nfor (VALUE v : values) { if (keep(v)) kept.add(v); }","handlingStrategy":"validation","validationCode":"// the values iterator is read-only: filter into your own collection instead\nList<VALUE> kept = new ArrayList<>();\nfor (VALUE v : values) { if (keep(v)) kept.add(v); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never call remove() on framework-supplied iterators.","Adapt to a List first when handing values to mutation-prone utilities."],"tags":["hadoop","mapreduce","iterator","reduce","unsupported-operation"],"backgroundTag":"unsupported-iterator-remove","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}