{"record":{"id":"43697fed0599469a","repo":"jwtk/jjwt","slug":"array-size-array-length-offset-offset-leng","errorCode":null,"errorMessage":"Array Size=${array.length}, offset=${offset}, length=${length}","messagePattern":"Array Size=(.+?), offset=(.+?), length=(.+?)","errorType":"exception","errorClass":"java.lang.IndexOutOfBoundsException","httpStatus":null,"severity":"error","filePath":"impl/src/main/java/io/jsonwebtoken/impl/io/CharSequenceReader.java","lineNumber":203,"sourceCode":"    }\n\n    /**\n     * Read the specified number of characters into the array.\n     *\n     * @param array  The array to store the characters in\n     * @param offset The starting position in the array to store\n     * @param length The maximum number of characters to read\n     * @return The number of characters read or -1 if there are\n     * no more\n     */\n    @Override\n    public int read(final char[] array, final int offset, final int length) {\n        if (idx >= end()) {\n            return Streams.EOF;\n        }\n        Objects.requireNonNull(array, \"array\");\n        if (length < 0 || offset < 0 || offset + length > array.length) {\n            throw new IndexOutOfBoundsException(\"Array Size=\" + array.length +\n                    \", offset=\" + offset + \", length=\" + length);\n        }\n\n        if (charSequence instanceof String) {\n            final int count = Math.min(length, end() - idx);\n            ((String) charSequence).getChars(idx, idx + count, array, offset);\n            idx += count;\n            return count;\n        }\n        if (charSequence instanceof StringBuilder) {\n            final int count = Math.min(length, end() - idx);\n            ((StringBuilder) charSequence).getChars(idx, idx + count, array, offset);\n            idx += count;\n            return count;\n        }\n        if (charSequence instanceof StringBuffer) {\n            final int count = Math.min(length, end() - idx);\n            ((StringBuffer) charSequence).getChars(idx, idx + count, array, offset);","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/jwtk/jjwt/blob/fb71496164c71442d08adec4571d9616ed5e1b8d/impl/src/main/java/io/jsonwebtoken/impl/io/CharSequenceReader.java#L185-L221","documentation":"Bounds guard in CharSequenceReader.read(char[], offset, length): thrown via Objects/validator checks when the destination array is null or offset/length are negative or exceed the array's size. The message echoes the array length, offset, and length so the caller can identify which argument violated read(char[], int, int)'s contract.","triggerScenarios":"Thrown at impl/src/main/java/io/jsonwebtoken/impl/io/CharSequenceReader.java:203 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure 0 <= offset and 0 <= length and offset + length <= array.length before calling read","Pass a non-null, adequately sized destination buffer","Fix the buffer-size computation (e.g. use Math.min(requested, array.length - offset))"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fb71496164c71442d08adec4571d9616ed5e1b8d","analyzedAt":"2026-09-09T00:33:09.982Z","contentChangedAt":"2026-09-09T00:33:09.982Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}