{"record":{"id":"032f90e2ca3b98ad","repo":"OpenFeign/feign","slug":"mark-not-supported-032f90","errorCode":null,"errorMessage":"Mark not supported","messagePattern":"Mark not supported","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"micrometer/src/main/java/feign/micrometer/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/micrometer/src/main/java/feign/micrometer/CountingInputStream.java#L67-L95","documentation":"Micrometer's CountingInputStream.reset() throws IOException(\"Mark not supported\") when the wrapped InputStream does not support mark/reset. The stream must be re-readable for metrics metering of request bodies, and reset() is only valid when the underlying stream advertises markSupported().","triggerScenarios":"The underlying Client's stream (e.g. a raw socket stream from HttpURLConnection without buffering) lacks mark support and something calls reset() on the metered stream.","commonSituations":"Custom Client implementations returning non-buffered streams; retry logic or repeated body reads forcing a reset on a non-markable stream (e.g. chunked transfer streams).","solutions":["Wrap the input stream in BufferedInputStream before MeteredClient sees it (BufferedInputStream supports mark)","Fix the custom Client to return a mark-supporting stream","Avoid code paths that reset the response stream; consume it once","If you control the source, buffer the body into a ByteArrayInputStream"],"exampleFix":"// before\nreturn new MeteredInputStream(registry, conn.getInputStream(), ...);\n// after\nreturn new MeteredInputStream(registry, new BufferedInputStream(conn.getInputStream()), ...);","handlingStrategy":"validation","validationCode":"InputStream raw = conn.getInputStream();\nif (!raw.markSupported()) raw = new BufferedInputStream(raw);","typeGuard":"boolean resetSafe(InputStream is){ return is.markSupported(); }","tryCatchPattern":"try { stream.reset(); }\ncatch (IOException e) {\n  if (\"Mark not supported\".equals(e.getMessage())) throw new IllegalStateException(\"wrap stream in BufferedInputStream\", e);\n  throw e;\n}","preventionTips":["Always wrap non-markable streams in BufferedInputStream","Assume chunked/socket streams do not support mark","Consume response streams once instead of resetting"],"tags":["io","stream","micrometer","mark-reset"],"backgroundTag":"unsupported-operation","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"}