hussein-awala commented on code in PR #11609: URL: https://github.com/apache/iceberg/pull/11609#discussion_r1852072895
########## core/src/main/java/org/apache/iceberg/TableMetadataParser.java: ########## @@ -277,11 +287,21 @@ public static TableMetadata read(FileIO io, String path) { public static TableMetadata read(FileIO io, InputFile file) { Codec codec = Codec.fromFileName(file.location()); - try (InputStream is = file.newStream(); - InputStream gis = codec == Codec.GZIP ? new GZIPInputStream(is) : is) { + InputStream is = file.newStream(); + // if codec is GZIP, is will be closed by GZIPInputStream + // otherwise, os will be closed by try-with-resources + try (InputStream gis = codec == Codec.GZIP ? new GZIPInputStream(is) : is) { Review Comment: This was the original code, but there is an edge case where the `GzipInputStream` throws an exception in its constructor, and it does not close the InputStream passed as an argument in this case, which according to the PR that introduced the bug could increase memory usage and lead to unexpected results. -- 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