{"record":{"id":"f8c21c98be0e7dbc","repo":"eclipse-vertx/vert.x","slug":"cannot-read-directory-file-does-not-exist","errorCode":null,"errorMessage":"Cannot read directory ${file}. Does not exist","messagePattern":"Cannot read directory (.+?)\\. Does not exist","errorType":"exception","errorClass":"FileSystemException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/file/impl/FileSystemImpl.java","lineNumber":814,"sourceCode":"            + \"' at \" + parentDir;\n          throw new FileSystemException(message, e);\n        }\n      }\n    };\n  }\n\n  private BlockingAction<List<String>> readDirInternal(String path) {\n    return readDirInternal(path, null);\n  }\n\n  private BlockingAction<List<String>> readDirInternal(String p, String filter) {\n    Objects.requireNonNull(p);\n    return new BlockingAction<List<String>>() {\n      public List<String> perform() {\n        try {\n          File file = resolveFile(p);\n          if (!file.exists()) {\n            throw new FileSystemException(\"Cannot read directory \" + file + \". Does not exist\");\n          }\n          if (!file.isDirectory()) {\n            throw new FileSystemException(\"Cannot read directory \" + file + \". It's not a directory\");\n          } else {\n            FilenameFilter fnFilter;\n            if (filter != null) {\n              Pattern fnPattern = Pattern.compile(filter);\n              fnFilter = new FilenameFilter() {\n                public boolean accept(File dir, String name) {\n                  return fnPattern.matcher(name).matches();\n                }\n              };\n            } else {\n              fnFilter = null;\n            }\n            File[] files;\n            if (fnFilter == null) {\n              files = file.listFiles();","sourceCodeStart":796,"sourceCodeEnd":832,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/file/impl/FileSystemImpl.java#L796-L832","documentation":"Wrapped error in readDirInternal: the directory listing operation threw an IOException before the explicit existence/isDirectory checks could produce a precise message. The raw path p is reported; the real cause (permissions, I/O error during listFiles) is in the cause chain.","triggerScenarios":"Calling FileSystem.readDir(path) (any overload, with or without filter) with a path that does not exist on the filesystem.","commonSituations":"Typos in the directory path, assuming a working-directory-relative path resolves where the app actually runs, or a directory that a previous setup step failed to create.","solutions":["Inspect the exception cause for the underlying I/O error","Verify the directory exists, is a directory, and is readable by the process"],"exampleFix":"// before\nvertx.fileSystem().readDir(\"/data/conf\").onSuccess(...);\n// after\nvertx.fileSystem().exists(\"/data/conf\")\n  .compose(exists -> exists ? vertx.fileSystem().readDir(\"/data/conf\")\n                             : vertx.fileSystem().mkdir(\"/data/conf\"))\n  .onSuccess(files -> ...);","handlingStrategy":"try-catch","validationCode":"if (!vertx.fileSystem().existsBlocking(dir)) {\n  throw new IllegalArgumentException(\"Directory does not exist: \" + dir);\n}","typeGuard":null,"tryCatchPattern":"try {\n  fs.readDir(dir);\n} catch (FileSystemException e) {\n  logger.warn(\"Cannot read dir {}: {}\", dir, e.getMessage());\n  return List.of(); // or create the directory\n}","preventionTips":["Check existsBlocking before listing","Use absolute paths or verify the process working directory","Create required directories during deployment/startup"],"tags":["filesystem","io","directory"],"backgroundTag":"directory-not-found","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"}