hudi-agent commented on code in PR #19659:
URL: https://github.com/apache/hudi/pull/19659#discussion_r3809879095


##########
hudi-io/src/main/java/org/apache/hudi/storage/HoodieStorage.java:
##########
@@ -329,60 +330,73 @@ public final void createImmutableFileInPath(StoragePath 
path,
   public final void createImmutableFileInPath(StoragePath path,
                                               Option<HoodieInstantWriter> 
contentWriter,
                                               boolean needTempFile) throws 
HoodieIOException {
-    OutputStream fsout = null;
     StoragePath tmpPath = null;
+    StoragePath pathToCreate = path;
+    if (contentWriter.isPresent() && needTempFile) {
+      StoragePath parent = path.getParent();
+      tmpPath = new StoragePath(parent, path.getName() + "." + 
UUID.randomUUID());
+      pathToCreate = tmpPath;
+    }
 
-    try {
-      if (!contentWriter.isPresent()) {
-        fsout = create(path, false);
-      }
-
-      if (contentWriter.isPresent() && needTempFile) {
-        StoragePath parent = path.getParent();
-        tmpPath = new StoragePath(parent, path.getName() + "." + 
UUID.randomUUID());
-        fsout = create(tmpPath, false);
-        contentWriter.get().writeToStream(fsout);
-      }
-
-      if (contentWriter.isPresent() && !needTempFile) {
-        fsout = create(path, false);
+    boolean contentWritten = false;

Review Comment:
   🤖 For the non-temp path (object stores, where `needCreateTempFile()` is 
false) `pathToCreate` is the final `path`. If `writeToStream` throws mid-write, 
try-with-resources still calls `close()` before the catch runs, and some 
object-store streams finalize the upload on close — potentially publishing 
partial content at the target. Since `tmpPath` is null there, 
`deleteTemporaryFile` is a no-op and nothing removes it. Is that 
acceptable/pre-existing, or worth guarding for the non-temp case too?
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



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

Reply via email to