apache/hadoop · warning · UnsupportedOperationException

mark not supported

Error message

mark not supported

What it means

S3ARemoteInputStream.mark() always throws UnsupportedOperationException("mark not supported"). This inner stream of the prefetching S3A input stream supports positional reads and seek, but not the mark/reset protocol of java.io.InputStream.

Source

Thrown at hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/prefetch/S3ARemoteInputStream.java:473

    if (closed) {
      throw new IOException(
          name + ": " + FSExceptionMessages.STREAM_IS_CLOSED);
    }
  }

  protected void throwIfInvalidSeek(long pos) throws EOFException {
    if (pos < 0) {
      throw new EOFException(FSExceptionMessages.NEGATIVE_SEEK + " " + pos);
    } else if (pos > this.getBlockData().getFileSize()) {
      throw new EOFException(FSExceptionMessages.CANNOT_SEEK_PAST_EOF + " " + pos);
    }
  }

  // Unsupported functions.

  @Override
  public void mark(int readlimit) {
    throw new UnsupportedOperationException("mark not supported");
  }

  @Override
  public void reset() {
    throw new UnsupportedOperationException("reset not supported");
  }

  @Override
  public long skip(long n) {
    throw new UnsupportedOperationException("skip not supported");
  }
}

View on GitHub (pinned to 2add963021)

Solutions

  1. Do not call mark() on this stream; use seek(getPos()) to reposition instead.
  2. If a library needs mark/reset, wrap the stream in BufferedInputStream (its markSupported() is true and it buffers internally).
  3. Check markSupported() before calling mark() in shared utility code.
  4. Use the public S3A FSDataInputStream API rather than the internal S3ARemoteInputStream.

Example fix

// before
stream.mark(1024); // UnsupportedOperationException on S3ARemoteInputStream

// after
if (stream.markSupported()) {
  stream.mark(1024);
} else {
  long markPos = stream.getPos(); // reposition with seek later
}
// or: BufferedInputStream buffered = new BufferedInputStream(stream);
//     buffered.mark(1024); buffered.reset();
Defensive patterns

Strategy: validation

Validate before calling

if (stream.markSupported()) {
  stream.mark(readlimit);
} else {
  markPos = stream.getPos(); // fall back to seek-based checkpoint
}

Prevention

When it happens

Trigger: Calling mark() on S3ARemoteInputStream directly (tests, extracted inner stream); generic libraries that unconditionally call mark() without checking markSupported() (some parsers, compression codecs).

Common situations: Third-party readers that rely on BufferedInputStream semantics being handed the raw remote stream; unit tests exercising mark on prefetch block data; debugging code that grabs the inner stream.

Related errors


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