adoroszlai commented on code in PR #8015:
URL: https://github.com/apache/ozone/pull/8015#discussion_r1983777336


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/IOUtils.java:
##########
@@ -95,4 +104,20 @@ public static void closeQuietly(AutoCloseable... 
closeables) {
   public static void closeQuietly(Collection<? extends AutoCloseable> 
closeables) {
     close(null, closeables);
   }
+
+  /** Write {@code properties} to the file at {@code path}, truncating any 
existing content. */
+  public static void writePropertiesToFile(Path path, Properties properties) 
throws IOException {
+    StringWriter out = new StringWriter();
+    properties.store(out, null);
+    Files.write(path, out.toString().getBytes(UTF_8));

Review Comment:
   Thanks @szetszwo for the review.
   
   > always first write to a tmp file and then rename
   
   Then I'll change it to:
   
   ```java
       try (OutputStream out = new AtomicFileOutputStream(file)) {
         properties.store(out, null);
       }
   ```
   
   using `AtomicFileOutputStream` from Ratis.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to