{"record":{"id":"4ac1c6b58106762f","repo":"quarkusio/quarkus","slug":"failed-to-access","errorCode":null,"errorMessage":"Failed to access ","messagePattern":"Failed to access ","errorType":"exception","errorClass":"java.lang.RuntimeException","httpStatus":null,"severity":"error","filePath":"independent-projects/bootstrap/app-model/src/main/java/io/quarkus/paths/ArchivePathTree.java","lineNumber":418,"sourceCode":"        public Path getPath(String resourceName) {\n            lock.readLock().lock();\n            try {\n                ensureOpen();\n                return resolveEntryPath(resourceName);\n            } finally {\n                lock.readLock().unlock();\n            }\n        }\n\n        /**\n         * Make sure you use this method inside a lock.\n         */\n        private void ensureOpen() {\n            // let's not use isOpen() as ensureOpen() is always used inside a read lock\n            if (open) {\n                return;\n            }\n            throw new RuntimeException(\"Failed to access \" + ArchivePathTree.this.getRoots()\n                    + \" because the FileSystem has been closed\");\n        }\n\n        @Override\n        public void close() throws IOException {\n            lock.writeLock().lock();\n            try {\n                open = false;\n                rootPath = null;\n                fs.close();\n            } catch (IOException e) {\n                throw e;\n            } finally {\n                // even when we close the fs, everything is kept as is in the fs instance\n                // and typically the cen, which is quite large\n                // let's make sure the fs is nullified for it to be garbage collected\n                fs = null;\n                lock.writeLock().unlock();","sourceCodeStart":400,"sourceCodeEnd":436,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/paths/ArchivePathTree.java#L400-L436","documentation":"OpenArchivePathTree (the open handle returned by ArchivePathTree.open()) validates it is still open inside its read lock before any read operation. Once the handle's close() has run — typically because the try-with-resources block exited — further reads throw RuntimeException('Failed to access <roots> because the FileSystem has been closed').","triggerScenarios":"Calling apply/accept/walk/walkRaw/walkIfContains/contains on an OpenPathTree obtained from ArchivePathTree.open() after that handle was closed, e.g. using it outside the try-with-resources scope, storing it in a field, or using it from another thread after close.","commonSituations":"Keeping a reference to the open tree beyond the try-with-resources block; async/worker threads reading a handle the main thread already closed; caching OpenPathTree instances for reuse.","solutions":["Keep all reads inside the try-with-resources block that opened the tree; re-open via ArchivePathTree.open() for later access","Use the ArchivePathTree itself (which opens/closes per operation) instead of holding a long-lived OpenPathTree","Ensure worker threads finish before closing the handle (synchronize/latch)","Do not cache OpenPathTree instances; cache the ArchivePathTree and open on demand"],"exampleFix":"// before\nOpenPathTree open = tree.open();\nopen.walk(visitor);\nopen.close();\nopen.contains(\"x\"); // throws: closed\n// after\ntry (OpenPathTree open = tree.open()) {\n    open.walk(visitor);\n    open.contains(\"x\");\n}","handlingStrategy":"try-catch","validationCode":"// ensure all reads happen inside the open scope\ntry (OpenPathTree open = tree.open()) {\n    // all reads here only\n}","typeGuard":"boolean usable(OpenPathTree t) {\n    try { t.contains(\"META-INF/MANIFEST.MF\"); return true; }\n    catch (RuntimeException e) { return false; } // closed FS\n}","tryCatchPattern":"try {\n    open.walk(visitor);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"has been closed\")) {\n        try (OpenPathTree reopened = tree.open()) { reopened.walk(visitor); }\n    } else { throw e; }\n}","preventionTips":["Never let OpenPathTree references escape try-with-resources scope","Coordinate async workers with latches before closing handles","Cache ArchivePathTree, not OpenPathTree instances","Re-open per operation instead of reusing closed handles"],"tags":["resource-closed","zip-filesystem","lifecycle","threading"],"backgroundTag":"filesystem-closed","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"}