Skip to content

Commit

Permalink
[BEAM-7813] FileIO.write() doesn't fail when writing to invalid bucket
Browse files Browse the repository at this point in the history
`writer` shouldn't be closed in `flush()` otherwise FileIO.write()
doesn't fail when writing to unhealthy channel. It's safe to just
`flush` instead of `close` because channel is closed after writing
in the parent scope anyway.
  • Loading branch information
ihji committed Jul 31, 2019
1 parent f03b6ba commit c6eb09c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,8 @@ public void flush() throws IOException {
if (getFooter() != null) {
writer.println(getFooter());
}
writer.close();
// BEAM-7813: don't close writer here
writer.flush();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ public void write(GenericRecord element) throws IOException {

@Override
public void flush() throws IOException {
// the only way to completely flush the output is to call writer.close() here
writer.close();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,7 @@ public void write(T element) throws IOException {
@Override
public void flush() throws IOException {
outputStream.write(("\n</" + getRootElement() + ">").getBytes(Charset.forName(getCharset())));
outputStream.flush();
}
}
}

0 comments on commit c6eb09c

Please sign in to comment.