OpenFeign/feign · error · IOException
Mark not supported
Error message
Mark not supported
What it means
The metrics5 CountingInputStream.reset() throws IOException("Mark not supported") when the wrapped stream does not support mark/reset. Behavior is identical to the metrics4 variant; mark support is delegated to the underlying stream.
Solutions
- Wrap the source in a BufferedInputStream before CountingInputStream
- Check markSupported() before resetting
- Call mark() before reading
Example fix
// before new CountingInputStream(connection.getInputStream(), clock); // after new CountingInputStream(new BufferedInputStream(connection.getInputStream()), clock);
Defensive patterns
Strategy: validation
Validate before calling
if (in.markSupported()) { /* safe to reset */ } Try / catch
try {
in.reset();
} catch (IOException e) {
// fall back to re-requesting the resource
} Prevention
- Buffer network streams before wrapping in metrics CountingInputStream
- Verify markSupported() before reset
- Mark before read when replay is expected
When it happens
Trigger: Calling reset() on a feign.metrics5 CountingInputStream whose underlying stream has markSupported() == false.
Common situations: Re-reading response bodies for retries/metrics when the source is an unbuffered network stream.
Related errors
AI-assisted analysis of OpenFeign/feign@e2a1e27560 (2026-09-10).
Data as JSON: /api/errors/2825b2758aa68b55.
Report an issue: GitHub.
Appendix: source
Thrown at dropwizard-metrics5/src/main/java/feign/metrics5/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)