{"record":{"id":"f33f1e1e32cf6c09","repo":"OpenFeign/feign","slug":"mark-not-set","errorCode":null,"errorMessage":"Mark not set","messagePattern":"Mark not set","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"dropwizard-metrics4/src/main/java/feign/metrics4/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/dropwizard-metrics4/src/main/java/feign/metrics4/CountingInputStream.java#L70-L95","documentation":"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.","triggerScenarios":"Calling reset() on a CountingInputStream without having called mark(readlimit) first, so the internal mark field is still -1.","commonSituations":"Retry or replay logic that resets a body stream before marking it; assuming CountingInputStream auto-marks at construction.","solutions":["Call mark(readlimit) before the first read if you plan to reset","Check that your reset path always follows a mark call","Restructure code to re-request the resource instead of resetting an unmarked stream"],"exampleFix":"// before\nint first = in.read();\nin.reset();\n// after\nin.mark(8192);\nint first = in.read();\nin.reset();","handlingStrategy":"validation","validationCode":"if (in.markSupported() && marked) { in.reset(); }","typeGuard":null,"tryCatchPattern":"try {\n  in.reset();\n} catch (IOException e) {\n  // mark was not set; re-acquire the stream\n}","preventionTips":["Always call mark(readlimit) before reading when reset may be needed","Track marked state explicitly in stream-handling code"],"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"}