Skip to content

Commit 2425888

Browse files
Flossyclaude
andcommitted
fix: Add null check for parent directory in S3VolumeManager.downloadFile()
Fixes #212 Added null validation for localPath.getParent() before calling Files.createDirectories() to prevent NullPointerException in edge cases where the path has no parent directory. Changes: - Store parent path in variable before checking - Only call Files.createDirectories() if parent is non-null - Add comment explaining the check While rare in practice (would require unusual volume path configurations), this defensive check prevents crashes when dealing with root-level paths or unusual temporary directory structures. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 232d1a2 commit 2425888

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

jplatform-storage-s3/src/main/java/org/flossware/jplatform/storage/s3/S3VolumeManager.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,12 @@ public void downloadFile(String volumeName, String relativePath) throws IOExcept
265265
}
266266

267267
Path localPath = getVolumePath(volumeName).resolve(relativePath);
268-
Files.createDirectories(localPath.getParent());
268+
269+
// Create parent directories if parent exists
270+
Path parent = localPath.getParent();
271+
if (parent != null) {
272+
Files.createDirectories(parent);
273+
}
269274

270275
try {
271276
String s3Key = buildS3Key(volumeName, relativePath);

0 commit comments

Comments
 (0)