findepi commented on code in PR #11220: URL: https://github.com/apache/iceberg/pull/11220#discussion_r1797751041
########## core/src/main/java/org/apache/iceberg/TableMetadataParser.java: ########## @@ -122,13 +122,23 @@ 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; - OutputStream stream = overwrite ? outputFile.createOrOverwrite() : outputFile.create(); - try (OutputStream ou = isGzip ? new GZIPOutputStream(stream) : stream; - OutputStreamWriter writer = new OutputStreamWriter(ou, StandardCharsets.UTF_8)) { - JsonGenerator generator = JsonUtil.factory().createGenerator(writer); - generator.useDefaultPrettyPrinter(); - toJson(metadata, generator); - generator.flush(); + try (OutputStream os = overwrite ? outputFile.createOrOverwrite() : outputFile.create()) { + if (isGzip) { + try (OutputStream gos = new GZIPOutputStream(os); + OutputStreamWriter osw = new OutputStreamWriter(gos, StandardCharsets.UTF_8)) { + JsonGenerator generator = JsonUtil.factory().createGenerator(os); + generator.useDefaultPrettyPrinter(); + toJson(metadata, generator); + generator.flush(); + } + } else { + try (OutputStreamWriter osw = new OutputStreamWriter(os, StandardCharsets.UTF_8)) { Review Comment: thanks! > Is there a gradle target to auto-format? ``` ./gradlew -DallModules=true spotlessApply ``` ( see also https://gist.github.com/findepi/da2ea85d095eaa0f3cfdcbb311ff59ed#reformat-code ) -- 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