{"record":{"id":"9a88fc8f752e0b9f","repo":"apache/cassandra","slug":"cannot-read-from-an-empty-path","errorCode":null,"errorMessage":"Cannot read from an empty path","messagePattern":"Cannot read from an empty path","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/io/util/File.java","lineNumber":800,"sourceCode":"\n    public File withSuffix(String suffix)\n    {\n        if (path == null)\n            throw new IllegalStateException(\"Cannot suffix an empty path\");\n        return new File(path.getParent().resolve(path.getFileName().toString() + suffix));\n    }\n\n    private Path toPathForWrite()\n    {\n        if (path == null)\n            throw new IllegalStateException(\"Cannot write to an empty path\");\n        return path;\n    }\n\n    private Path toPathForRead()\n    {\n        if (path == null)\n            throw new IllegalStateException(\"Cannot read from an empty path\");\n        return path;\n    }\n\n    @VisibleForTesting\n    public static FileSystem unsafeGetFilesystem()\n    {\n        return filesystem;\n    }\n\n    public static void unsafeSetFilesystem(FileSystem fs)\n    {\n        filesystem = fs;\n    }\n}\n\n","sourceCodeStart":782,"sourceCodeEnd":816,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/util/File.java#L782-L816","documentation":"Thrown by File.toPathForRead() when a read operation is attempted on a File whose internal path is null. The Cassandra I/O File wrapper requires a non-null path to resolve to a java.nio.file.Path for reading. It indicates the File object was constructed without a path (e.g. via a null-argument constructor path) and is unusable for reads.","triggerScenarios":"Calling any read-oriented method (e.g. newInputStream, toPathForRead-backed APIs) on org.apache.cassandra.io.util.File whose `path` field is null — typically a File built from a null String or null parent.","commonSituations":"Passing null configuration values (data/saved-caches paths) into file APIs; deserializing or programmatically constructing a File without validating the path; API migration where callers previously used java.io.File (which tolerated null less strictly at a later stage).","solutions":["Find where the File was constructed and fix the null path source (check config/env for the path value).","Validate the path string is non-null/non-empty before constructing File.","Use File.isEmpty() or similar check to guard read calls."],"exampleFix":"// before\nFile f = new File(config.commitLogDir); // config value null\nf.newInputStream();\n\n// after\nif (config.commitLogDir == null || config.commitLogDir.isEmpty())\n    throw new IllegalStateException(\"commitLogDir must be configured\");\nFile f = new File(config.commitLogDir);\nf.newInputStream();","handlingStrategy":"validation","validationCode":"if (path == null || path.isEmpty()) throw new IllegalArgumentException(\"path must be configured\");","typeGuard":"boolean isReadable(File f) { return f != null && !f.isEmpty(); }","tryCatchPattern":"try { file.newInputStream(); } catch (IllegalStateException e) { /* handle null path */ }","preventionTips":["Validate configured paths at startup before any file I/O.","Never pass nullable config values directly into File construction.","Add assertions on File state in helper methods."],"tags":["io","null-path","file"],"backgroundTag":"empty-required-field","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}