jsancio commented on a change in pull request #9512: URL: https://github.com/apache/kafka/pull/9512#discussion_r535482262
########## File path: raft/src/main/java/org/apache/kafka/snapshot/FileRawSnapshotWriter.java ########## @@ -74,18 +74,19 @@ public void freeze() throws IOException { frozen = true; // Set readonly and ignore the result - if (!path.toFile().setReadOnly()) { - throw new IOException(String.format("Unable to set file %s as read-only", path)); + if (!tempSnapshotPath.toFile().setReadOnly()) { + throw new IOException(String.format("Unable to set file (%s) as read-only", tempSnapshotPath)); } - Path destination = Snapshots.moveRename(path, snapshotId); - Files.move(path, destination, StandardCopyOption.ATOMIC_MOVE); + Path destination = Snapshots.moveRename(tempSnapshotPath, snapshotId); + Files.move(tempSnapshotPath, destination, StandardCopyOption.ATOMIC_MOVE); } @Override public void close() throws IOException { channel.close(); - Files.deleteIfExists(path); + // This is a noop if freeze was called before calling close + Files.deleteIfExists(tempSnapshotPath); Review comment: Yes! ---------------------------------------------------------------- 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