{"record":{"id":"c20f5c5b623709f3","repo":"OpenFeign/feign","slug":"mark-not-set-c20f5c","errorCode":null,"errorMessage":"Mark not set","messagePattern":"Mark not set","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"dropwizard-metrics5/src/main/java/feign/metrics5/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-metrics5/src/main/java/feign/metrics5/CountingInputStream.java#L70-L95","documentation":"In CountingInputStream.reset (dropwizard-metrics5), the wrapped stream supports mark/reset and reset() was called, but mark() was never invoked first, so the recorded byte-count snapshot is the -1 sentinel and the underlying stream has no mark position to return to. This means reset() is being called without a prior mark() on this counting wrapper.","triggerScenarios":"Calling reset() on feign.metrics5 CountingInputStream before ever calling mark(readlimit).","commonSituations":"Retry/replay code that resets the body stream without marking first.","solutions":["Call mark(int readlimit) on the stream before any reset()","Guard reset() with markSupported() and a 'mark set' check, or track mark state explicitly","Restructure reading logic so reset is only used after a valid mark","If the wrapped stream never supports marking, avoid reset entirely"],"exampleFix":"// before\nin.reset();\n// after\nin.mark(8192);\n// ... 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 missing; re-acquire stream\n}","preventionTips":["Call mark(readlimit) immediately after stream creation if reset will be used","Do not assume CountingInputStream auto-marks"],"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"}