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

View File

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