Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: awildturtok <1553491+awildturtok@users.noreply.github.com>
  • Loading branch information
SebChmie and awildturtok authored Mar 12, 2024
1 parent 01cb649 commit 36247df
Showing 1 changed file with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,7 @@ private static void dumpToFile(byte[] gzippedObj, @NonNull String keyOfDump, Exc
}

try {
/*
Files::createDirectories creates a directory by creating all nonexistent parent directories first.
Each directory creation attempt uses Files::createDirectory, through Files::createAndCheckIsDirectory.
Files::createDirectory is atomic and Files::createAndCheckIsDirectory catches and ignores FileAlreadyExistsException for directories.
Thus, after leaving Files::createDirectories the parent of dumpfile exists.
*/
// This will create all necessary parent directories.
Files.createDirectories(dumpfile.toPath().getParent());

// Should be a redundant check, due to the above reasoning
Expand All @@ -310,8 +305,7 @@ private static void dumpToFile(byte[] gzippedObj, @NonNull String keyOfDump, Exc
}
}
catch (IOException e) {
// Files::createDirectories throws java.io.IOException
throw new IllegalStateException("Could not create `%s` due to an IOException:%s".formatted(dumpfile.getParentFile(), e.getMessage()));
log.warn("Could not create `{}`", dumpfile.getParentFile(), e);
}

// Write json
Expand Down

0 comments on commit 36247df

Please sign in to comment.