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


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/io/HoodieAppendHandle.java:
##########
@@ -549,6 +569,7 @@ public void write(Map<String, HoodieRecord<T>> recordMap) {
       appendDataAndDeleteBlocks(header, true);
       estimatedNumberOfBytesWritten += averageRecordSize * numberOfRecords;
     } catch (Exception e) {

Review Comment:
   🤖 Closing the writer here (good for the leak) but not calling `markClosed()` 
means the handle ends up in a half-state: `writer == null` but `isClosed()` is 
still `false`. If any caller ever wraps `write(recordMap)` in a try-finally and 
then calls `close()`, `close()` will skip the early-return, reach 
`appendDataAndDeleteBlocks(...)`, and NPE on `writer.appendBlocks(...)` / 
`writer.getLogFile()`. Current callers (`HoodieSparkMergeOnReadTable`, 
`HoodieFlinkMergeOnReadTable`) do `write(); close();` without finally so this 
is latent, but would calling `markClosed()` here too be a cheap way to make the 
contract safe for future try-with-resources style use?
   
   <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