hachikuji commented on a change in pull request #10749:
URL: https://github.com/apache/kafka/pull/10749#discussion_r648724939



##########
File path: raft/src/main/java/org/apache/kafka/snapshot/Snapshots.java
##########
@@ -68,15 +68,22 @@ public static Path snapshotPath(Path logDir, OffsetAndEpoch 
snapshotId) {
         return snapshotDir(logDir).resolve(filenameFromSnapshotId(snapshotId) 
+ SUFFIX);
     }
 
-    public static Path createTempFile(Path logDir, OffsetAndEpoch snapshotId) 
throws IOException {
+    public static Path createTempFile(Path logDir, OffsetAndEpoch snapshotId) {
         Path dir = snapshotDir(logDir);
+        Path tempFile;
 
-        // Create the snapshot directory if it doesn't exists
-        Files.createDirectories(dir);
-
-        String prefix = String.format("%s-", 
filenameFromSnapshotId(snapshotId));
+        try {
+            // Create the snapshot directory if it doesn't exists
+            Files.createDirectories(dir);
 
-        return Files.createTempFile(dir, prefix, PARTIAL_SUFFIX);
+            String prefix = String.format("%s-", 
filenameFromSnapshotId(snapshotId));
+            tempFile = Files.createTempFile(dir, prefix, PARTIAL_SUFFIX);

Review comment:
       nit: couldn't we return here and remove `tempFile`?

##########
File path: 
raft/src/main/java/org/apache/kafka/snapshot/FileRawSnapshotWriter.java
##########
@@ -78,7 +85,11 @@ public void append(MemoryRecords records) {
             checkIfFrozen("Append");
             Utils.writeFully(channel, records.buffer());
         } catch (IOException e) {
-            throw new RuntimeException(e);
+            throw new UncheckedIOException(
+                String.format("Error writing file snapshot," +

Review comment:
       nit: missing a space after the comma. Also, it would be nice to be 
consistent with the use of comma vs period for the similar cases in this file




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to