Skip to content

Commit

Permalink
Add check in ScheduledReporter's stop method
Browse files Browse the repository at this point in the history
Refs #4246
Refs #4135
  • Loading branch information
ummels authored and joschi committed Oct 3, 2024
1 parent 17e6f52 commit 0b5cf55
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,13 @@ public void stop() {
executor.shutdown(); // Disable new tasks from being submitted
}

try {
report(); // Report metrics one last time
} catch (Exception e) {
LOG.warn("Final reporting of metrics failed.", e);
if (this.scheduledFuture != null) {
// Reporter started, try to report metrics one last time
try {
report();
} catch (Exception e) {
LOG.warn("Final reporting of metrics failed.", e);
}
}

if (shutdownExecutorOnStop) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ void closesConnectionIfGraphiteIsUnavailable() throws Exception {

@Test
void closesConnectionOnReporterStop() throws Exception {
reporter.start(1, TimeUnit.SECONDS);
reporter.stop();

final InOrder inOrder = inOrder(graphite);
Expand Down

0 comments on commit 0b5cf55

Please sign in to comment.