Skip to content

Commit

Permalink
Add check in ScheduledReporter's stop method (#4246)
Browse files Browse the repository at this point in the history
Closes #4135
  • Loading branch information
ummels authored Oct 3, 2024
1 parent 80a0e2d commit f0bb90d
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 @@ -445,6 +445,7 @@ public void closesConnectionIfGraphiteIsUnavailable() throws Exception {

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

final InOrder inOrder = inOrder(graphite);
Expand Down

0 comments on commit f0bb90d

Please sign in to comment.