{"record":{"id":"77be6d2021c66b42","repo":"eclipse-vertx/vert.x","slug":"failed-to-delete-path","errorCode":null,"errorMessage":"Failed to delete ${path}","messagePattern":"Failed to delete (.+?)","errorType":"exception","errorClass":"FileSystemException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/file/impl/FileSystemImpl.java","lineNumber":676,"sourceCode":"          throw new FileSystemException(getFileAccessErrorMessage(\"read\", link), e);\n        }\n      }\n    };\n  }\n\n  private BlockingAction<Void> deleteInternal(String path) {\n    return deleteInternal(path, false);\n  }\n\n  private BlockingAction<Void> deleteInternal(String path, boolean recursive) {\n    Objects.requireNonNull(path);\n    return new BlockingAction<Void>() {\n      public Void perform() {\n        try {\n          Path source = resolveFile(path).toPath();\n          delete(source, recursive);\n        } catch (IOException e) {\n          throw new FileSystemException(getFileAccessErrorMessage(\"delete\", path), e);\n        }\n        return null;\n      }\n    };\n  }\n\n  public static void delete(Path path, boolean recursive) throws IOException {\n    if (recursive) {\n      Files.walkFileTree(path, new SimpleFileVisitor<Path>() {\n        public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {\n          Files.delete(file);\n          return FileVisitResult.CONTINUE;\n        }\n        public FileVisitResult postVisitDirectory(Path dir, IOException e) throws IOException {\n          if (e == null) {\n            Files.delete(dir);\n            return FileVisitResult.CONTINUE;\n          } else {","sourceCodeStart":658,"sourceCodeEnd":694,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/file/impl/FileSystemImpl.java#L658-L694","documentation":"Thrown when FileSystem.delete / deleteRecursive fails: Vert.x resolves the path and deletes it (recursively if requested), wrapping any IOException into a FileSystemException via getFileAccessErrorMessage(\"delete\", path) — 'Failed to delete <path>'. It indicates the OS refused or could not complete the deletion.","triggerScenarios":"vertx.fileSystem().delete(path, recursive) on a non-empty directory with recursive=false (DirectoryNotEmptyException), missing write permission on the parent directory, files locked/open on Windows, or a missing path.","commonSituations":"Deleting a temp/cache directory that still has children; cleanup code on Windows while files are memory-mapped or open; read-only container layers; NFS 'stale file handle' during recursive deletes.","solutions":["Pass recursive=true when deleting a non-empty directory.","Ensure the process has write+execute permission on the parent directory and, for recursive deletes, on all children.","Close all open files/streams before deleting (especially on Windows).","Check getCause() for DirectoryNotEmptyException vs AccessDeniedException to pick the right fix."],"exampleFix":"// before\nvertx.fileSystem().deleteBlocking(\"/tmp/cache\"); // DirectoryNotEmptyException\n// after\nvertx.fileSystem().delete(\"/tmp/cache\", true);","handlingStrategy":"try-catch","validationCode":"FileSystem fs = vertx.fileSystem();\nif (fs.existsBlocking(path) && fs.propsBlocking(path).isDirectory() && fs.readDirBlocking(path).size() > 0 && !recursive) throw new IllegalStateException(\"directory not empty: \" + path);","typeGuard":null,"tryCatchPattern":"try { vertx.fileSystem().deleteBlocking(path); } catch (FileSystemException e) { if (e.getCause() instanceof DirectoryNotEmptyException) { vertx.fileSystem().deleteBlockingRecursive(path); } else throw e; }","preventionTips":["Use recursive=true for non-empty directories","Close all open file handles before delete","Verify write permission on the parent directory","Treat missing path as already-deleted (idempotent cleanup)"],"tags":["filesystem","delete","io","directory"],"backgroundTag":"file-delete-failed","analyzedSha":"fb308bd8c3f12c79f4ae89bef67fadf6c80d036e","analyzedAt":"2026-09-06T11:37:12.241Z","contentChangedAt":"2026-09-06T11:37:12.241Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}