apache/hadoop · error · IOException

Mark/reset not supported

Error message

Mark/reset not supported

What it means

CryptoInputStream.markSupported() returns false and mark(int) is a silent no-op, because decryptors are stateful (stream offset, IV progression) so a mark/reset cannot be honored even when the wrapped stream supports it. reset() therefore always throws IOException("Mark/reset not supported").

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/CryptoInputStream.java:690

  @Override
  public int available() throws IOException {
    checkStream();
    
    return in.available() + outBuffer.remaining();
  }

  @Override
  public boolean markSupported() {
    return false;
  }
  
  @Override
  public void mark(int readLimit) {
  }
  
  @Override
  public void reset() throws IOException {
    throw new IOException("Mark/reset not supported");
  }

  @Override
  public boolean seekToNewSource(long targetPos) throws IOException {
    Preconditions.checkArgument(targetPos >= 0, 
        "Cannot seek to negative offset.");
    checkStream();
    if (!(in instanceof Seekable)) {
      throw new UnsupportedOperationException(in.getClass().getCanonicalName()
          + " does not support seekToNewSource.");
    }
    boolean result = ((Seekable) in).seekToNewSource(targetPos);
    resetStreamOffset(targetPos);
    return result;
  }

  @Override
  public ByteBuffer read(ByteBufferPool bufferPool, int maxLength,

View on GitHub (pinned to 2add963021)

Solutions

  1. Guard with if (in.markSupported()) before any mark/reset and take an alternate path when false
  2. Read the header bytes into a byte[] and parse from memory instead of mark/probe/rewind
  3. Reopen the stream at the original offset instead of reset()

Example fix

// before
in.mark(64);
probeHeader(in);
in.reset(); // IOException: Mark/reset not supported

// after
byte[] header = new byte[64];
IOUtils.readFully(in, header, 0, header.length); // no rewind needed
probeHeader(header);
Defensive patterns

Strategy: validation

Validate before calling

if (in.markSupported()) {
  in.mark(readLimit);
  try { probe(in); } finally { in.reset(); }
} else {
  // buffered/manual strategy: read header into byte[] and parse from memory
}

Try / catch

try {
  in.reset();
} catch (IOException e) {
  if ("Mark/reset not supported".equals(e.getMessage())) {
    in = reopenAt(savedPos); // recover by reopening
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: Calling reset() on any CryptoInputStream — the check is unconditional, not an instanceof probe of the inner stream; mark-then-reset format sniffing in parsers hits this on encrypted streams.

Common situations: Libraries that branch on InputStream marking (format detectors, serialization frameworks) applied to encrypted HDFS data; code ported from plain streams that assumed mark/reset was available.

Related errors


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