jwtk/jjwt · error · java.io.IOException

mark/reset not supported

Error message

mark/reset not supported

What it means

BaseNCodecInputStream never supports mark/reset: reset() is a guard that unconditionally throws IOException. It fires whenever a caller (e.g. code wrapping the decoded stream in a PushbackInputStream-like flow or calling reset directly after mark) attempts to reposition a Base64/Base32/Base16 decoding stream, which cannot buffer arbitrary look-ahead.

Source

Thrown at impl/src/main/java/io/jsonwebtoken/impl/io/BaseNCodecInputStream.java:206

                // Return the amount read or EOF
                return readLen != 0 ? readLen : -1;
            }
            readLen += read;
        }
        return readLen;
    }

    /**
     * Repositions this stream to the position at the time the mark method was last called on this input stream.
     * <p>
     * The {@link #reset} method of {@link BaseNCodecInputStream} does nothing except throw an {@link IOException}.
     *
     * @throws IOException if this method is invoked
     * @since 1.7
     */
    @Override
    public synchronized void reset() throws IOException {
        throw new IOException("mark/reset not supported");
    }

    /**
     * {@inheritDoc}
     *
     * @throws IllegalArgumentException if the provided skip length is negative
     * @since 1.7
     */
    @Override
    public long skip(final long n) throws IOException {
        if (n < 0) {
            throw new IllegalArgumentException("Negative skip length: " + n);
        }

        // skip in chunks of 512 bytes
        final byte[] b = new byte[512];
        long todo = n;

View on GitHub (pinned to fb71496164)

Solutions

  1. Check InputStream#markSupported() before calling mark/reset and avoid reset on this stream type
  2. Wrap the stream in a BufferedInputStream with a sufficient buffer size if mark/reset semantics are required
  3. Read the full stream into a byte[] (or use IOUtils.toByteArray) and re-open a new stream from the buffer to 'replay' the data
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at impl/src/main/java/io/jsonwebtoken/impl/io/BaseNCodecInputStream.java:206 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of jwtk/jjwt@fb71496164 (2026-09-09). Data as JSON: /api/errors/1dfcc976911b4b84. Report an issue: GitHub.