This is an automated email from the ASF dual-hosted git repository.
runzhiwang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ratis.git
The following commit(s) were added to refs/heads/master by this push:
new cf9ed08 RATIS-1051. Use try-resource-block when saveMd5File (#190)
cf9ed08 is described below
commit cf9ed0864615e82083f6be5f4f958563dbf242ad
Author: maobaolong <[email protected]>
AuthorDate: Tue Sep 8 21:10:32 2020 +0800
RATIS-1051. Use try-resource-block when saveMd5File (#190)
---
ratis-common/src/main/java/org/apache/ratis/util/MD5FileUtil.java | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/ratis-common/src/main/java/org/apache/ratis/util/MD5FileUtil.java
b/ratis-common/src/main/java/org/apache/ratis/util/MD5FileUtil.java
index 3bd4df0..d7201ca 100644
--- a/ratis-common/src/main/java/org/apache/ratis/util/MD5FileUtil.java
+++ b/ratis-common/src/main/java/org/apache/ratis/util/MD5FileUtil.java
@@ -150,9 +150,10 @@ public abstract class MD5FileUtil {
File md5File = getDigestFileForFile(dataFile);
String md5Line = digestString + " *" + dataFile.getName() + "\n";
- AtomicFileOutputStream afos = new AtomicFileOutputStream(md5File);
- afos.write(md5Line.getBytes(StandardCharsets.UTF_8));
- afos.close();
+ try (AtomicFileOutputStream afos
+ = new AtomicFileOutputStream(md5File)) {
+ afos.write(md5Line.getBytes(StandardCharsets.UTF_8));
+ }
if (LOG.isDebugEnabled()) {
LOG.debug("Saved MD5 " + digestString + " to " + md5File);