{"record":{"id":"4ef00723a78f4154","repo":"apache/hadoop","slug":"invalid-buffer-isdirect-should-be","errorCode":null,"errorMessage":"Invalid buffer, isDirect should be {}","messagePattern":"Invalid buffer, isDirect should be (.+?)","errorType":"exception","errorClass":"HadoopIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/rawcoder/ByteBufferDecodingState.java","lineNumber":111,"sourceCode":"  /**\n   * Check and ensure the buffers are of the desired length and type, direct\n   * buffers or not.\n   * @param buffers the buffers to check\n   */\n  void checkInputBuffers(ByteBuffer[] buffers) {\n    int validInputs = 0;\n\n    for (ByteBuffer buffer : buffers) {\n      if (buffer == null) {\n        continue;\n      }\n\n      if (buffer.remaining() != decodeLength) {\n        throw new HadoopIllegalArgumentException(\n            \"Invalid buffer, not of length \" + decodeLength);\n      }\n      if (buffer.isDirect() != usingDirectBuffer) {\n        throw new HadoopIllegalArgumentException(\n            \"Invalid buffer, isDirect should be \" + usingDirectBuffer);\n      }\n\n      validInputs++;\n    }\n\n    if (validInputs < decoder.getNumDataUnits()) {\n      throw new HadoopIllegalArgumentException(\n          \"No enough valid inputs are provided, not recoverable\");\n    }\n  }\n\n  /**\n   * Check and ensure the buffers are of the desired length and type, direct\n   * buffers or not.\n   * @param buffers the buffers to check\n   */\n  void checkOutputBuffers(ByteBuffer[] buffers) {","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/rawcoder/ByteBufferDecodingState.java#L93-L129","documentation":"Error \"Invalid buffer, isDirect should be {}\" thrown in apache/hadoop.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass buffers whose isDirect() matches the coder's preferDirectBuffer() setting: direct ByteBuffers for direct coders, heap-backed buffers otherwise.","Allocate buffers with ByteBuffer.allocateDirect() when the coder expects direct buffers."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}