apache/hadoop · error · HadoopIllegalArgumentException

Invalid buffer, isDirect should be {}

Error message

Invalid buffer, isDirect should be {}

What it means

Error "Invalid buffer, isDirect should be {}" thrown in apache/hadoop.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/rawcoder/ByteBufferDecodingState.java:111

  /**
   * Check and ensure the buffers are of the desired length and type, direct
   * buffers or not.
   * @param buffers the buffers to check
   */
  void checkInputBuffers(ByteBuffer[] buffers) {
    int validInputs = 0;

    for (ByteBuffer buffer : buffers) {
      if (buffer == null) {
        continue;
      }

      if (buffer.remaining() != decodeLength) {
        throw new HadoopIllegalArgumentException(
            "Invalid buffer, not of length " + decodeLength);
      }
      if (buffer.isDirect() != usingDirectBuffer) {
        throw new HadoopIllegalArgumentException(
            "Invalid buffer, isDirect should be " + usingDirectBuffer);
      }

      validInputs++;
    }

    if (validInputs < decoder.getNumDataUnits()) {
      throw new HadoopIllegalArgumentException(
          "No enough valid inputs are provided, not recoverable");
    }
  }

  /**
   * Check and ensure the buffers are of the desired length and type, direct
   * buffers or not.
   * @param buffers the buffers to check
   */
  void checkOutputBuffers(ByteBuffer[] buffers) {

View on GitHub (pinned to 2add963021)

Solutions

  1. Pass buffers whose isDirect() matches the coder's preferDirectBuffer() setting: direct ByteBuffers for direct coders, heap-backed buffers otherwise.
  2. Allocate buffers with ByteBuffer.allocateDirect() when the coder expects direct buffers.

When it happens

Trigger: Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/rawcoder/ByteBufferDecodingState.java:111 when the library encounters an invalid state.

Common situations: Occurs when a decoding buffer's directness does not match the coder's expectation (direct vs heap ByteBuffer). Allocate buffers matching the coder's isDirect requirement.


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/4ef00723a78f4154. Report an issue: GitHub.