Ensure server log is flushed when shutting down the runtime, whether in crash or normally.
Helps avoid situations where a server crash is hard to diagnose because
the server log was not flushed and the last error messages got cut off.
RELNOTES: None.
@@ -671,9 +671,13 @@ public final class BlazeRuntime implements BugReport.BlazeRuntimeInterface {
/** Invokes {@link BlazeModule#blazeShutdown()} on all registered modules. */
public void shutdown() {
+ try {
for (BlazeModule module : blazeModules) {
module.blazeShutdown();
}
+ } finally {
+ flushServerLog();
+ }
}
public void prepareForAbruptShutdown() {
@@ -684,9 +688,13 @@ public final class BlazeRuntime implements BugReport.BlazeRuntimeInterface {
/** Invokes {@link BlazeModule#blazeShutdownOnCrash()} on all registered modules. */
public void shutdownOnCrash() {
+ try {
for (BlazeModule module : blazeModules) {
module.blazeShutdownOnCrash();
}
+ } finally {
+ flushServerLog();
+ }
}
/**
