pvary commented on a change in pull request #1559:
URL: https://github.com/apache/iceberg/pull/1559#discussion_r500810584



##########
File path: 
core/src/main/java/org/apache/iceberg/hadoop/HadoopTableOperations.java
##########
@@ -294,13 +294,25 @@ private void writeVersionHint(int versionToWrite) {
     Path versionHintFile = versionHintFile();
     FileSystem fs = getFileSystem(versionHintFile, conf);
 
-    try (FSDataOutputStream out = fs.create(versionHintFile, true /* overwrite 
*/)) {
-      
out.write(String.valueOf(versionToWrite).getBytes(StandardCharsets.UTF_8));
+    try {
+      if (fs.exists(versionHintFile)) {
+        Path tempVersionHintFile = metadataPath("version-hint.temp" );
+        writeFileToPath(fs, tempVersionHintFile);
+        fs.delete(versionHintFile, false);
+        fs.rename(tempVersionHintFile, versionHintFile);
+      } else {
+        writeFileToPath(fs, versionHintFile);
+      }
     } catch (IOException e) {
       LOG.warn("Failed to update version hint", e);
     }
   }
 
+  private void writeFileToPath(FileSystem fs, Path path) throws IOException{

Review comment:
       Formatting checks might fail here.
   
   I have learned that it is worth to run checkstyle checks before committing:
   ```
   ./gradlew build -x test
   ```




----------------------------------------------------------------
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:
[email protected]



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

Reply via email to