delei commented on code in PR #1034:
URL: https://github.com/apache/fesod/pull/1034#discussion_r3838697132


##########
fesod-sheet/src/main/java/org/apache/fesod/sheet/write/metadata/holder/WriteWorkbookHolder.java:
##########
@@ -240,12 +240,15 @@ public WriteWorkbookHolder(WriteWorkbook writeWorkbook) {
         }
 
         // init handler
-        initHandler(writeWorkbook, null);
-
         try {
+            initHandler(writeWorkbook, null);
             copyTemplate();
         } catch (IOException e) {
+            closeOutputStreamIfOwned();

Review Comment:
   could we gate `closeOutputStreamIfOwned()` with `autoCloseStream` instead of 
`file != null?`
   
   `autoCloseStream` is more consistent with existing close behavior (while 
still not closing caller-provided streams).
   



##########
fesod-sheet/src/main/java/org/apache/fesod/sheet/write/metadata/holder/WriteWorkbookHolder.java:
##########
@@ -240,12 +240,15 @@ public WriteWorkbookHolder(WriteWorkbook writeWorkbook) {
         }
 
         // init handler
-        initHandler(writeWorkbook, null);
-
         try {
+            initHandler(writeWorkbook, null);
             copyTemplate();
         } catch (IOException e) {
+            closeOutputStreamIfOwned();

Review Comment:
   Could we gate `closeOutputStreamIfOwned()` with `autoCloseStream` instead of 
`file != null?`
   
   `autoCloseStream` is more consistent with existing close behavior (while 
still not closing caller-provided streams).
   



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