{"record":{"id":"3844b7f93b552404","repo":"jwtk/jjwt","slug":"io-exception-t-getmessage","errorCode":null,"errorMessage":"IO Exception: ${t.getMessage()}","messagePattern":"IO Exception: (.+?)","errorType":"exception","errorClass":"java.io.IOException","httpStatus":null,"severity":"error","filePath":"impl/src/main/java/io/jsonwebtoken/impl/io/FilteredInputStream.java","lineNumber":137,"sourceCode":"            super.close();\n        } catch (Throwable t) {\n            onThrowable(t);\n        }\n    }\n\n    /**\n     * Handle any Throwable thrown; by default, throws the given exception.\n     * <p>\n     * This method provides a point to implement custom exception\n     * handling. The default behavior is to re-throw the exception.\n     * </p>\n     *\n     * @param t The IOException thrown\n     * @throws IOException if an I/O error occurs.\n     */\n    protected void onThrowable(final Throwable t) throws IOException {\n        if (t instanceof IOException) throw (IOException) t;\n        throw new IOException(\"IO Exception: \" + t.getMessage(), t);\n    }\n\n    /**\n     * Invokes the delegate's {@code mark(int)} method.\n     *\n     * @param readlimit read ahead limit\n     */\n    @Override\n    public synchronized void mark(final int readlimit) {\n        in.mark(readlimit);\n    }\n\n    /**\n     * Invokes the delegate's {@code markSupported()} method.\n     *\n     * @return true if mark is supported, otherwise false\n     */\n    @Override","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/jwtk/jjwt/blob/fb71496164c71442d08adec4571d9616ed5e1b8d/impl/src/main/java/io/jsonwebtoken/impl/io/FilteredInputStream.java#L119-L155","documentation":"FilteredInputStream wraps any non-IOException Throwable raised by its delegate stream operations (read, skip, available, close, reset) into an IOException with the message 'IO Exception: <msg>'. If the original is already an IOException it is rethrown unchanged.","triggerScenarios":"Any read/skip/available/close/reset call on a FilteredInputStream whose delegate throws (e.g. a RuntimeException from a custom stream, or a non-IO Throwable during stream processing).","commonSituations":"Custom delegate streams throwing unchecked exceptions; streams over sockets that break mid-read; reset() called when the delegate does not support marking (markSupported() false).","solutions":["Inspect the exception cause: if it is already an IOException, handle that error directly.","Call markSupported() before calling reset(); guard against unsupported reset.","Ensure the underlying stream (file, socket) is open and available for the whole read.","Wrap custom delegate stream code so unchecked exceptions don't leak into IO operations."],"exampleFix":"// before\nin.reset(); // throws IOException if mark not supported\n// after\nif (in.markSupported()) { in.reset(); } else { throw new IllegalStateException(\"reset not supported\"); }","handlingStrategy":"try-catch","validationCode":"// Java\nif (in == null) throw new IllegalArgumentException(\"InputStream cannot be null\");\nif (wantReset && !in.markSupported()) throw new IllegalStateException(\"reset unsupported\");","typeGuard":"static boolean supportsReset(InputStream in) {\n    return in != null && in.markSupported();\n}","tryCatchPattern":"try {\n    int n = filteredIn.read(buf);\n} catch (IOException e) {\n    Throwable cause = e.getCause();\n    if (cause instanceof RuntimeException) throw (RuntimeException) cause;\n    throw e;\n}","preventionTips":["Check markSupported() before reset().","Keep delegate streams open for the entire lifecycle of the filtered stream.","Wrap custom InputStream implementations to prevent unchecked exceptions escaping read().","Always close streams in finally/try-with-resources."],"tags":["io","stream","inputstream"],"backgroundTag":"file-read-failed","analyzedSha":"fb71496164c71442d08adec4571d9616ed5e1b8d","analyzedAt":"2026-09-09T00:33:09.982Z","contentChangedAt":"2026-09-09T00:33:09.982Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}