{"record":{"id":"62104739945d0aee","repo":"OpenFeign/feign","slug":"mark-not-supported","errorCode":null,"errorMessage":"Mark not supported","messagePattern":"Mark not supported","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"dropwizard-metrics4/src/main/java/feign/metrics4/CountingInputStream.java","lineNumber":85,"sourceCode":"\n  @Override\n  public long skip(long n) throws IOException {\n    final long result = in.skip(n);\n    count += result;\n    return result;\n  }\n\n  @Override\n  public synchronized void mark(int readlimit) {\n    in.mark(readlimit);\n    mark = count;\n    // it's okay to mark even if mark isn't supported, as reset won't work\n  }\n\n  @Override\n  public synchronized void reset() throws IOException {\n    if (!in.markSupported()) {\n      throw new IOException(\"Mark not supported\");\n    }\n    if (mark == -1) {\n      throw new IOException(\"Mark not set\");\n    }\n\n    in.reset();\n    count = mark;\n  }\n}\n","sourceCodeStart":67,"sourceCodeEnd":95,"githubUrl":"https://github.com/OpenFeign/feign/blob/e2a1e27560a1e68840c34f031afca88b36096e30/dropwizard-metrics4/src/main/java/feign/metrics4/CountingInputStream.java#L67-L95","documentation":"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.","triggerScenarios":"Calling reset() on a CountingInputStream whose underlying stream (e.g. a raw socket stream or one wrapped without BufferedInputStream) has markSupported() == false.","commonSituations":"Retry/interceptor logic trying to re-read a response body; reading directly from network streams that do not buffer.","solutions":["Wrap the source stream in a BufferedInputStream before constructing CountingInputStream","Check markSupported() before calling reset()","Call mark() before reading if you intend to reset"],"exampleFix":"// before\nInputStream in = new CountingInputStream(rawStream, clock);\n// after\nInputStream in = new CountingInputStream(new BufferedInputStream(rawStream), clock);","handlingStrategy":"validation","validationCode":"if (in.markSupported()) { /* safe to reset */ }","typeGuard":null,"tryCatchPattern":"try {\n  in.reset();\n} catch (IOException e) {\n  // re-fetch or re-open the stream instead\n}","preventionTips":["Wrap unbuffered/network streams in BufferedInputStream","Check markSupported() before relying on reset","Call mark() before any read if reset is planned"],"tags":["io","stream","mark-reset"],"backgroundTag":"mark-not-supported","analyzedSha":"e2a1e27560a1e68840c34f031afca88b36096e30","analyzedAt":"2026-09-10T12:37:37.238Z","contentChangedAt":"2026-09-10T12:37:37.238Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}