OpenFeign/feign · error · IOException

Mark not set

Error message

Mark not set

What it means

CountingInputStream.reset() throws IOException("Mark not set") when mark() was never called before reset(). The wrapper tracks its own mark value; a mark of -1 means no mark position exists to restore.

Solutions

  1. Call mark(readlimit) before the first read if you plan to reset
  2. Check that your reset path always follows a mark call
  3. Restructure code to re-request the resource instead of resetting an unmarked stream

Example fix

// before
int first = in.read();
in.reset();
// after
in.mark(8192);
int first = in.read();
in.reset();
Defensive patterns

Strategy: validation

Validate before calling

if (in.markSupported() && marked) { in.reset(); }

Try / catch

try {
  in.reset();
} catch (IOException e) {
  // mark was not set; re-acquire the stream
}

Prevention

When it happens

Trigger: Calling reset() on a CountingInputStream without having called mark(readlimit) first, so the internal mark field is still -1.

Common situations: Retry or replay logic that resets a body stream before marking it; assuming CountingInputStream auto-marks at construction.

Related errors


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

Appendix: source

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

    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)