{"record":{"id":"0f32e2756491e11a","repo":"eclipse-vertx/vert.x","slug":"file-handle-is-closed","errorCode":null,"errorMessage":"File handle is closed","messagePattern":"File handle is closed","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/file/impl/AsyncFileImpl.java","lineNumber":513,"sourceCode":"        } else {\n          // It's been fully written\n          done();\n        }\n      }\n\n      public void failed(Throwable t, Object attachment) {\n        promise.fail(t);\n      }\n    });\n  }\n\n  private void check() {\n    checkClosed();\n  }\n\n  private void checkClosed() {\n    if (closed) {\n      throw new IllegalStateException(\"File handle is closed\");\n    }\n  }\n\n  private void checkContext() {\n    if (!vertx.getContext().equals(context)) {\n      throw new IllegalStateException(\"AsyncFile must only be used in the context that created it, expected: \"\n          + context + \" actual \" + vertx.getContext());\n    }\n  }\n\n  private void doClose(Promise<Void> handler) {\n    context.<Void>executeBlockingInternal(() -> {\n      ch.close();\n      return null;\n    }).onComplete(handler);\n  }\n\n  private synchronized void closeInternal(Promise<Void> handler) {","sourceCodeStart":495,"sourceCodeEnd":531,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/file/impl/AsyncFileImpl.java#L495-L531","documentation":"Lifecycle guard in AsyncFileImpl: an operation was attempted on an AsyncFile whose underlying file handle has already been closed (the internal 'closed' flag is set). Every read/write/flush path funnels through checkClosed(), so any post-close use fails fast with this IllegalStateException instead of touching a dead handle.","triggerScenarios":"Thrown at vertx-core/src/main/java/io/vertx/core/file/impl/AsyncFileImpl.java:513 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Track closure (e.g. via the close future) and skip operations after close","Sequence operations so close() happens after all reads/writes complete"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fb308bd8c3f12c79f4ae89bef67fadf6c80d036e","analyzedAt":"2026-09-06T11:37:12.241Z","contentChangedAt":"2026-09-06T11:37:12.241Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}