{"record":{"id":"46c1afa17dee3a06","repo":"OpenFeign/feign","slug":"mark-not-set-46c1af","errorCode":null,"errorMessage":"Mark not set","messagePattern":"Mark not set","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"micrometer/src/main/java/feign/micrometer/CountingInputStream.java","lineNumber":88,"sourceCode":"    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":70,"sourceCodeEnd":95,"githubUrl":"https://github.com/OpenFeign/feign/blob/e2a1e27560a1e68840c34f031afca88b36096e30/micrometer/src/main/java/feign/micrometer/CountingInputStream.java#L70-L95","documentation":"CountingInputStream.reset() throws IOException(\"Mark not set\") when reset() is called before any mark() has established a position (internal mark field is -1). Per InputStream contract, reset is only valid after a prior mark.","triggerScenarios":"Calling reset() on the metered stream without ever calling mark(), or after the mark was invalidated; consuming more than readlimit then resetting.","commonSituations":"Custom retry/replay logic reading the response body twice; utility code assuming reset() always works; misuse of the CountingInputStream outside the Feign pipeline.","solutions":["Call mark(readlimit) before any read if you plan to reset","Restructure code to read the stream once and buffer the bytes if re-reading is needed","Check markSupported() and your mark position logic before resetting"],"exampleFix":"// before\nis.read(); is.reset(); // Mark not set\n// after\nis.mark(8192);\nis.read();\nis.reset();","handlingStrategy":"validation","validationCode":"if (stream.markSupported() && markPositionSet) { stream.reset(); }","typeGuard":null,"tryCatchPattern":"try { stream.reset(); }\ncatch (IOException e) {\n  if (\"Mark not set\".equals(e.getMessage())) { stream.mark(8192); /* restart read */ }\n  else throw e;\n}","preventionTips":["Call mark(readlimit) before any reset","Track whether mark() was actually invoked","Buffer bytes if replay semantics are needed"],"tags":["io","stream","micrometer","mark-reset"],"backgroundTag":"invalid-state-transition","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"}