nastra commented on code in PR #11609:
URL: https://github.com/apache/iceberg/pull/11609#discussion_r1852346605


##########
core/src/main/java/org/apache/iceberg/TableMetadataParser.java:
##########
@@ -122,15 +122,25 @@ public static void write(TableMetadata metadata, 
OutputFile outputFile) {
   public static void internalWrite(
       TableMetadata metadata, OutputFile outputFile, boolean overwrite) {
     boolean isGzip = Codec.fromFileName(outputFile.location()) == Codec.GZIP;
-    try (OutputStream os = overwrite ? outputFile.createOrOverwrite() : 
outputFile.create();
-        OutputStream gos = isGzip ? new GZIPOutputStream(os) : os;
+    OutputStream os = overwrite ? outputFile.createOrOverwrite() : 
outputFile.create();
+    // if isGzip is true, os will be closed by GZIPOutputStream,
+    // otherwise, os will be closed by try-with-resources
+    try (OutputStream gos = isGzip ? new GZIPOutputStream(os) : os;

Review Comment:
   +1 to that idea. We should also use this for `ViewMetadataParser`



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to