Skip to content

Commit

Permalink
Revert "Core: Update TableMetadataParser to ensure all streams closed (
Browse files Browse the repository at this point in the history
…#11220)" (#11621)

This reverts commit 2b55fef.
  • Loading branch information
hussein-awala authored and RussellSpitzer committed Nov 21, 2024
1 parent 0b74d50 commit 4a43283
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions core/src/main/java/org/apache/iceberg/TableMetadataParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ 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;
OutputStreamWriter writer = new OutputStreamWriter(gos, StandardCharsets.UTF_8)) {
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);
Expand Down Expand Up @@ -275,9 +275,9 @@ 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) {
return fromJson(file, JsonUtil.mapper().readValue(gis, JsonNode.class));
try (InputStream is =
codec == Codec.GZIP ? new GZIPInputStream(file.newStream()) : file.newStream()) {
return fromJson(file, JsonUtil.mapper().readValue(is, JsonNode.class));
} catch (IOException e) {
throw new RuntimeIOException(e, "Failed to read file: %s", file);
}
Expand Down

0 comments on commit 4a43283

Please sign in to comment.