From 5eebafaa38165ad415256c586e31ebe6bb318c4d Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Thu, 28 Jul 2011 17:23:53 +0400 Subject: Improve shutdown of NotificationService --- .../java/org/sonar/server/notifications/NotificationService.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sonar-server/src/main/java/org/sonar/server/notifications/NotificationService.java b/sonar-server/src/main/java/org/sonar/server/notifications/NotificationService.java index 88184e1ed23..ae4f45f507a 100644 --- a/sonar-server/src/main/java/org/sonar/server/notifications/NotificationService.java +++ b/sonar-server/src/main/java/org/sonar/server/notifications/NotificationService.java @@ -59,6 +59,8 @@ public class NotificationService implements ServerComponent { private NotificationChannel[] channels; private NotificationDispatcher[] dispatchers; + private boolean stopping = false; + /** * Default constructor when no channels. */ @@ -86,7 +88,8 @@ public class NotificationService implements ServerComponent { public void stop() { try { - executorService.awaitTermination(delay, TimeUnit.SECONDS); + stopping = true; + executorService.awaitTermination(5, TimeUnit.SECONDS); executorService.shutdown(); } catch (InterruptedException e) { Logs.INFO.error("Error during stop of notification service", e); @@ -102,6 +105,9 @@ public class NotificationService implements ServerComponent { NotificationQueueElement queueElement = manager.getFromQueue(); while (queueElement != null) { deliver(queueElement.getNotification()); + if (stopping) { + break; + } queueElement = manager.getFromQueue(); } TIME_PROFILER.stop(); -- cgit v1.2.3