Skip to content

Commit aee1e2e

Browse files
meltsufinchingor13
authored andcommitted
Logging: call flush before close (#4784)
* Logging: call flush before close Also prevent more logs to be written after close. Fixes #4783. * code style fix
1 parent cda0b03 commit aee1e2e

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

  • google-cloud-clients/google-cloud-logging/src/main/java/com/google/cloud/logging

google-cloud-clients/google-cloud-logging/src/main/java/com/google/cloud/logging/LoggingImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,8 @@ public void flush() {
582582

583583
/* Write logs synchronously or asynchronously based on writeSynchronicity setting. */
584584
private void writeLogEntries(Iterable<LogEntry> logEntries, WriteOption... writeOptions) {
585+
if (closed) return;
586+
585587
switch (this.writeSynchronicity) {
586588
case SYNC:
587589
get(writeAsync(logEntries, writeOptions));
@@ -688,6 +690,7 @@ public void close() throws Exception {
688690
return;
689691
}
690692
closed = true;
693+
flush();
691694
rpc.close();
692695
}
693696

0 commit comments

Comments
 (0)