{"record":{"id":"ce723b2a3cd2fede","repo":"quarkusio/quarkus","slug":"failed-to-list-content-of","errorCode":null,"errorMessage":"Failed to list content of ","messagePattern":"Failed to list content of ","errorType":"exception","errorClass":"java.io.UncheckedIOException","httpStatus":null,"severity":"error","filePath":"independent-projects/bootstrap/app-model/src/main/java/io/quarkus/paths/DirectoryPathTree.java","lineNumber":71,"sourceCode":"    }\n\n    @Override\n    protected Path getContainerPath() {\n        return dir;\n    }\n\n    @Override\n    public boolean isOpen() {\n        return true;\n    }\n\n    @Override\n    public boolean isEmpty() {\n        if (Files.exists(dir)) {\n            try (Stream<Path> stream = Files.list(dir)) {\n                return stream.findAny().isEmpty();\n            } catch (IOException e) {\n                throw new UncheckedIOException(\"Failed to list content of \" + dir, e);\n            }\n        }\n        return true;\n    }\n\n    @Override\n    public void close() throws IOException {\n    }\n\n    @Override\n    public PathTree getOriginalTree() {\n        return this;\n    }\n\n    @Override\n    public Set<String> getResourceNames() {\n        return resourceNames == null ? resourceNames = super.getResourceNames() : resourceNames;\n    }","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/paths/DirectoryPathTree.java#L53-L89","documentation":"DirectoryPathTree.isEmpty() lists the directory contents to determine whether the tree holds any entries. If the underlying directory cannot be listed (e.g. permission denied, it is not actually a directory, or it was deleted concurrently), the IOException is wrapped in an UncheckedIOException with this message. It is thrown from a boolean-looking API, so callers rarely expect it.","triggerScenarios":"Calling isEmpty() on a DirectoryPathTree whose dir exists but cannot be opened by Files.list(): insufficient OS read permission, the path was replaced by a file/symlink to a file between Files.exists and Files.list, or an I/O error on a network/EFS mount.","commonSituations":"Running the app as a user without read access to a classpath directory; a hot-reload/dev-mode race where a directory is removed or recreated while Quarkus scans it; a mounted volume going offline.","solutions":["Check OS permissions on the directory and ensure the process user can read it (ls -ld, chmod/chown).","Verify the path is actually a directory and still exists at call time; re-create the PathTree if the underlying path changed.","If the directory is on a network mount, check mount health and retry.","Catch UncheckedIOException at the call site and treat as 'cannot scan' if that is acceptable."],"exampleFix":"// before\nPathTree tree = PathTree.ofDirectoryOrFile(somePath, null);\nboolean empty = tree.isEmpty(); // throws UncheckedIOException on unreadable dir\n// after\nif (!Files.isDirectory(somePath) || !Files.isReadable(somePath)) {\n    throw new IllegalStateException(\"Directory missing or unreadable: \" + somePath);\n}\nboolean empty = PathTree.ofDirectoryOrFile(somePath, null).isEmpty();","handlingStrategy":"validation","validationCode":"if (!Files.isDirectory(dir) || !Files.isReadable(dir)) {\n    throw new IllegalStateException(\"Directory missing or unreadable: \" + dir);\n}","typeGuard":"static boolean isListableDirectory(Path dir) {\n    return dir != null && Files.isDirectory(dir) && Files.isReadable(dir);\n}","tryCatchPattern":"try {\n    boolean empty = tree.isEmpty();\n} catch (UncheckedIOException e) {\n    log.warnf(\"Cannot list %s: %s\", dir, e.getCause());\n    // treat as non-scannable\n}","preventionTips":["Check Files.isDirectory and Files.isReadable before constructing DirectoryPathTree.","Be aware dev-mode/reload can delete directories concurrently; re-validate before scanning.","Watch permissions in containerized deployments (run as non-root users).","Catch UncheckedIOException at scan boundaries rather than letting it abort the whole operation."],"tags":["io","filesystem","unchecked-ioexception","quarkus-paths"],"backgroundTag":"directory-unreadable","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}