apache/flink · error · IndexOutOfBoundsException

Range [off=%d, len=%d] out of bounds for buffer of length %d

Error message

Range [off=%d, len=%d] out of bounds for buffer of length %d

What it means

Error "Range [off=%d, len=%d] out of bounds for buffer of length %d" thrown in apache/flink.

Source

Thrown at flink-filesystems/flink-s3-fs-native/src/main/java/org/apache/flink/fs/s3native/NativeS3InputStream.java:312

            ensureStreamOpen();
            int data = bufferedStream.read();
            if (data != -1) {
                nextReadPos++;
                streamPos++;
            }
            return data;
        } finally {
            lock.unlock();
        }
    }

    @Override
    public int read(byte[] b, int off, int len) throws IOException {
        if (b == null) {
            throw new NullPointerException("Read buffer must not be null");
        }
        if (off < 0 || len < 0 || len > b.length - off) {
            throw new IndexOutOfBoundsException(
                    String.format(
                            "Range [off=%d, len=%d] out of bounds for buffer of length %d",
                            off, len, b.length));
        }
        if (len == 0) {
            return 0;
        }
        lock();
        try {
            if (closed) {
                throw new IOException("Stream is closed");
            }
            if (nextReadPos >= contentLength) {
                return -1;
            }
            lazySeek();
            ensureStreamOpen();
            long remaining = contentLength - nextReadPos;

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Address the cause reported by the error message: Range [off=the reported value, len=the reported value] out of bounds for buffer of length the reported value
  2. Verify the inputs, configuration values, and classpath/dependency setup related to this operation, then retry.

Example fix

Correct the condition described ("Range [off=the reported value, len=the reported value] out of bounds for buffer of length the reported value") and rerun the job or command.

When it happens

Trigger: Triggered at runtime when the operation fails because: Range [off=the reported value, len=the reported value] out of bounds for buffer of length the reported value.

Common situations: Commonly caused by misconfiguration, missing dependencies or files, unsupported types or operations, or invalid user input leading to: Range [off=the reported value, len=the reported value] out of bounds for buffer of length the reported value.


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/d0a88774562e139d. Report an issue: GitHub.