133tosakarin commented on code in PR #1142:
URL: https://github.com/apache/ratis/pull/1142#discussion_r1756268351
##########
ratis-server/src/main/java/org/apache/ratis/server/storage/SnapshotManager.java:
##########
@@ -88,7 +89,8 @@ private FileChannel open(FileChunkProto chunk, File
tmpSnapshotFile) throws IOEx
}
// create the temp snapshot file and put padding inside
out = FileUtils.newFileChannel(tmpSnapshotFile,
StandardOpenOption.WRITE, StandardOpenOption.CREATE);
- digester.get().reset();
+ digester = newMd5Digest();
+ digester.reset();
Review Comment:
That's ok!
In that case, it may need to be written like this
`Subject: [PATCH] rearrange the order of updateCurrentTerm
---
Index:
ratis-server/src/main/java/org/apache/ratis/server/storage/SnapshotManager.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git
a/ratis-server/src/main/java/org/apache/ratis/server/storage/SnapshotManager.java
b/ratis-server/src/main/java/org/apache/ratis/server/storage/SnapshotManager.java
---
a/ratis-server/src/main/java/org/apache/ratis/server/storage/SnapshotManager.java
(revision da67bf94f3d65e6e62a920b7a6f98f3d4e595e24)
+++
b/ratis-server/src/main/java/org/apache/ratis/server/storage/SnapshotManager.java
(date 1726126638779)
@@ -89,8 +89,7 @@
}
// create the temp snapshot file and put padding inside
out = FileUtils.newFileChannel(tmpSnapshotFile,
StandardOpenOption.WRITE, StandardOpenOption.CREATE);
- digester = newMd5Digest();
- digester.reset();
+ renewMd5Digest();
} else {
if (!exists) {
throw new FileNotFoundException("Chunk offset is non-zero but file
is not found: " + tmpSnapshotFile
@@ -173,9 +172,10 @@
}
}
- private MessageDigest newMd5Digest() throws IOException {
+ private void renewMd5Digest() throws IOException {
try {
- return MessageDigest.getInstance("MD5");
+ digester = MessageDigest.getInstance("MD5");
+ digester.reset();
} catch (NoSuchAlgorithmException e) {
throw new IOException("could not find MD5 digest algorithm");
}
`
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]