OpenFeign/feign · error · IOException

Mark not supported

Error message

Mark not supported

What it means

CountingInputStream.reset() throws IOException("Mark not supported") when the wrapped InputStream does not support mark/reset. The counting wrapper delegates mark support to the underlying stream, so reset is only valid if the inner stream supports it.

Solutions

  1. Wrap the source stream in a BufferedInputStream before constructing CountingInputStream
  2. Check markSupported() before calling reset()
  3. Call mark() before reading if you intend to reset

Example fix

// before
InputStream in = new CountingInputStream(rawStream, clock);
// after
InputStream in = new CountingInputStream(new BufferedInputStream(rawStream), clock);
Defensive patterns

Strategy: validation

Validate before calling

if (in.markSupported()) { /* safe to reset */ }

Try / catch

try {
  in.reset();
} catch (IOException e) {
  // re-fetch or re-open the stream instead
}

Prevention

When it happens

Trigger: Calling reset() on a CountingInputStream whose underlying stream (e.g. a raw socket stream or one wrapped without BufferedInputStream) has markSupported() == false.

Common situations: Retry/interceptor logic trying to re-read a response body; reading directly from network streams that do not buffer.

Related errors


AI-assisted analysis of OpenFeign/feign@e2a1e27560 (2026-09-10). Data as JSON: /api/errors/62104739945d0aee. Report an issue: GitHub.

Appendix: source

Thrown at dropwizard-metrics4/src/main/java/feign/metrics4/CountingInputStream.java:85

  @Override
  public long skip(long n) throws IOException {
    final long result = in.skip(n);
    count += result;
    return result;
  }

  @Override
  public synchronized void mark(int readlimit) {
    in.mark(readlimit);
    mark = count;
    // it's okay to mark even if mark isn't supported, as reset won't work
  }

  @Override
  public synchronized void reset() throws IOException {
    if (!in.markSupported()) {
      throw new IOException("Mark not supported");
    }
    if (mark == -1) {
      throw new IOException("Mark not set");
    }

    in.reset();
    count = mark;
  }
}

View on GitHub (pinned to e2a1e27560)