{"record":{"id":"a6c63d2c3897c312","repo":"apache/hadoop","slug":"tried-to-release-a-buffer-that-was-not-created-by","errorCode":null,"errorMessage":"tried to release a buffer that was not created by this stream.","messagePattern":"tried to release a buffer that was not created by this stream\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FSDataInputStream.java","lineNumber":231,"sourceCode":"  }\n\n  private static final EnumSet<ReadOption> EMPTY_READ_OPTIONS_SET =\n      EnumSet.noneOf(ReadOption.class);\n\n  final public ByteBuffer read(ByteBufferPool bufferPool, int maxLength)\n          throws IOException, UnsupportedOperationException {\n    return read(bufferPool, maxLength, EMPTY_READ_OPTIONS_SET);\n  }\n  \n  @Override\n  public void releaseBuffer(ByteBuffer buffer) {\n    try {\n      ((HasEnhancedByteBufferAccess)in).releaseBuffer(buffer);\n    }\n    catch (ClassCastException e) {\n      ByteBufferPool bufferPool = extendedReadBuffers.remove( buffer);\n      if (bufferPool == null) {\n        throw new IllegalArgumentException(\"tried to release a buffer \" +\n            \"that was not created by this stream.\");\n      }\n      bufferPool.putBuffer(buffer);\n    }\n  }\n\n  @Override\n  public void unbuffer() {\n    StreamCapabilitiesPolicy.unbuffer(in);\n  }\n\n  @Override\n  public boolean hasCapability(String capability) {\n    return StoreImplementationUtils.hasCapability(in, capability);\n  }\n\n  /**\n   * String value. Includes the string value of the inner stream","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FSDataInputStream.java#L213-L249","documentation":"Thrown by FSDataInputStream.releaseBuffer when the underlying stream lacks HasEnhancedByteBufferAccess and the buffer was not found in the stream's extendedReadBuffers registry. The buffer was never handed out by this stream, so releasing it is invalid.","triggerScenarios":"Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FSDataInputStream.java:231 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Only release buffers obtained from this stream's read(ByteBufferPool, ...) call.","Do not release the same buffer twice or release buffers allocated elsewhere."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}