apache/hadoop · error · UnsupportedOperationException

remove not supported.

Error message

remove not supported.

What it means

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.

Source

Thrown at hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/SortedRanges.java:379

        next = range.getEndIndex();
        
      }
    }
    
    /**
     * Get whether all the ranges have been skipped.
     * @return <code>true</code> if all ranges have been skipped.
     *         <code>false</code> otherwise.
     */
    synchronized boolean skippedAllRanges() {
      return !rangeIterator.hasNext() && next>range.getEndIndex();
    }
    
    /**
     * Remove is not supported. Doesn't apply.
     */
    public void remove() {
      throw new UnsupportedOperationException("remove not supported.");
    }
    
  }

}

View on GitHub (pinned to 2add963021)

Solutions

  1. Remove the remove() call — skip ranges are advanced only via next()/hasNext().
  2. If removal semantics are needed, materialize the indices into your own collection first and mutate that copy.

Example fix

// before
it.next();
it.remove();

// after
it.next(); // advance only; removal is not supported
Defensive patterns

Strategy: validation

Validate before calling

// never call remove() on SkipRangeIterator; advance only
while (skipIt.hasNext()) { long idx = skipIt.next(); /* use idx */ }

Prevention

When it happens

Trigger: 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.

Common situations: Utility methods written against java.util.Iterator that defensively call remove(); porting a reader that previously used a mutable ArrayList iterator.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/549d5f3cdab55070. Report an issue: GitHub.