Fix IntervalMetricReader breaking if export() throws. (#3044)

This commit is contained in:
Christian Neumüller 2021-03-19 17:24:49 +01:00 committed by GitHub
parent 085eb9d87c
commit 3528123c35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -117,7 +117,6 @@ public final class IntervalMetricReader {
} }
@Override @Override
@SuppressWarnings("BooleanParameter")
public void run() { public void run() {
// Ignore the CompletableResultCode from doRun() in order to keep run() asynchronous // Ignore the CompletableResultCode from doRun() in order to keep run() asynchronous
doRun(); doRun();
@ -141,8 +140,9 @@ public final class IntervalMetricReader {
flushResult.succeed(); flushResult.succeed();
exportAvailable.set(true); exportAvailable.set(true);
}); });
} catch (RuntimeException e) { } catch (Throwable t) {
logger.log(Level.WARNING, "Exporter threw an Exception", e); exportAvailable.set(true);
logger.log(Level.WARNING, "Exporter threw an Exception", t);
flushResult.fail(); flushResult.fail();
} }
} else { } else {

View File

@ -120,8 +120,9 @@ class IntervalMetricReaderTest {
.buildAndStart(); .buildAndStart();
try { try {
assertThat(waitingMetricExporter.waitForNumberOfExports(1)) assertThat(waitingMetricExporter.waitForNumberOfExports(2))
.containsExactly(Collections.singletonList(METRIC_DATA)); .containsExactly(
Collections.singletonList(METRIC_DATA), Collections.singletonList(METRIC_DATA));
} finally { } finally {
intervalMetricReader.shutdown(); intervalMetricReader.shutdown();
} }