{"record":{"id":"0a98cf7afe0a0b0e","repo":"didi/DoKit","slug":"mark-not-supported","errorCode":null,"errorMessage":"Mark not supported","messagePattern":"Mark not supported","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"Android/dokit/src/main/java/com/didichuxing/doraemonkit/kit/network/stream/InputStreamProxy.java","lineNumber":123,"sourceCode":"        }\n\n        return mSkipBuffer;\n    }\n\n    @Override\n    public boolean markSupported() {\n        // this can be implemented, but isn't needed for TeedInputStream's behavior\n        return false;\n    }\n\n    @Override\n    public void mark(int readlimit) {\n        // noop -- mark is not supported\n    }\n\n    @Override\n    public void reset() throws IOException {\n        throw new UnsupportedOperationException(\"Mark not supported\");\n    }\n\n    @Override\n    public void close() throws IOException {\n        super.close();\n        closeOutputStreamQuietly();\n    }\n\n    private synchronized void closeOutputStreamQuietly() {\n        if (!mClosed) {\n            try {\n                mOutputStream.close();\n            } catch (IOException e) {\n            } finally {\n                mClosed = true;\n            }\n        }\n    }","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/didi/DoKit/blob/626827cddb2feb2f3aee87a52a064b4e5ca2bed4/Android/dokit/src/main/java/com/didichuxing/doraemonkit/kit/network/stream/InputStreamProxy.java#L105-L141","documentation":"Thrown by InputStreamProxy.reset() because the proxy stream (used by DoKit to tee network/stream data to an output sink while it is consumed) explicitly does not support mark/reset — markSupported() returns false and mark() is a no-op. Calling reset() therefore fails with UnsupportedOperationException, as the proxy cannot rewind bytes already forwarded to the sink.","triggerScenarios":"Calling reset() (directly or via a library that conditionally resets, e.g. ImageDecoder or an XML parser that checks markSupported() incorrectly) on a stream wrapped by DoKit's InputStreamProxy; some code paths call reset() unconditionally before parsing.","commonSituations":"Third-party parsers or decoders that reset() when markSupported() is misreported; re-reading a response stream that DoKit wrapped for capture and expecting it to rewind like a BufferedInputStream","solutions":["Wrap the stream in a BufferedInputStream (or read it fully into a byte[] / ByteArrayInputStream) if you need rewind — the buffer provides mark/reset over the proxy","Check markSupported() before calling reset() at every reset site","Restructure to consume the stream once instead of resetting it; tee the bytes yourself if multiple passes are needed"],"exampleFix":"// before\nstream.reset(); // stream is an InputStreamProxy\n\n// after\nBufferedInputStream buffered = new BufferedInputStream(stream);\nbuffered.mark(limit);\n// ... read ...\nbuffered.reset(); // works: BufferedInputStream supplies mark/reset","handlingStrategy":"fallback","validationCode":"InputStream s = (stream.markSupported()) ? stream : new BufferedInputStream(stream);\n// later: if (s.markSupported()) s.reset();","typeGuard":"boolean canReset(InputStream in) { return in != null && in.markSupported(); }","tryCatchPattern":null,"preventionTips":["Always check markSupported() before mark()/reset()","Wrap DoKit-proxied streams in BufferedInputStream or read them fully into memory if re-reading is required"],"tags":["android","io","stream","unsupported-operation"],"backgroundTag":null,"analyzedSha":"626827cddb2feb2f3aee87a52a064b4e5ca2bed4","analyzedAt":"2026-08-14T12:45:58.758Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}