Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check in ScheduledReporter's stop method #4246

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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