{"record":{"id":"d33b4ea47c974f19","repo":"apache/hadoop","slug":"readbuffer-refcount-cannot-be-negative","errorCode":null,"errorMessage":"ReadBuffer refCount cannot be negative","messagePattern":"ReadBuffer refCount cannot be negative","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/ReadBuffer.java","lineNumber":165,"sourceCode":"\n  public ReadBufferStatus getStatus() {\n    return status;\n  }\n\n  public void setStatus(ReadBufferStatus status) {\n    this.status = status;\n    if (status == READ_FAILED) {\n      bufferindex = -1;\n    }\n  }\n\n  public void startReading() {\n    refCount.getAndIncrement();\n  }\n\n  public void endReading() {\n    if (refCount.decrementAndGet() < 0) {\n      throw new IllegalStateException(\"ReadBuffer refCount cannot be negative\");\n    }\n  }\n\n  public int getRefCount() {\n    return refCount.get();\n  }\n\n  public CountDownLatch getLatch() {\n    return latch;\n  }\n\n  public void setLatch(CountDownLatch latch) {\n    this.latch = latch;\n  }\n\n  public long getTimeStamp() {\n    return timeStamp;\n  }","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/ReadBuffer.java#L147-L183","documentation":"Error \"ReadBuffer refCount cannot be negative\" thrown in apache/hadoop.","triggerScenarios":"A ReadBuffer's reference count goes negative, i.e. released more times than acquired.","commonSituations":"See trigger scenarios.","solutions":["This indicates a buffer lifecycle bug; avoid double-release of read buffers in custom code.","Upgrade hadoop-azure and report with logs if observed in stock usage."],"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"}