]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10026 Avoid submitting callback tasks to the executor
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Tue, 31 Oct 2017 15:00:27 +0000 (16:00 +0100)
committerDuarte Meneses <duarte.meneses@sonarsource.com>
Mon, 6 Nov 2017 14:28:51 +0000 (15:28 +0100)
server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeProcessingSchedulerImpl.java
server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeProcessingSchedulerImplTest.java

index 6dec30bfdc85054f6710fcd133faabd30f220558..12b376398fc754d162c3653553fa8a14d308d240 100644 (file)
@@ -65,7 +65,7 @@ public class CeProcessingSchedulerImpl implements CeProcessingScheduler {
   public void startScheduling() {
     for (ChainingCallback chainingCallback : chainingCallbacks) {
       ListenableScheduledFuture<CeWorker.Result> future = executorService.schedule(chainingCallback.worker, delayBetweenEnabledTasks, timeUnit);
-      addCallback(future, chainingCallback, executorService);
+      addCallback(future, chainingCallback);
     }
   }
 
@@ -165,7 +165,7 @@ public class CeProcessingSchedulerImpl implements CeProcessingScheduler {
 
     private void addCallback() {
       if (workerFuture != null && keepRunning()) {
-        Futures.addCallback(workerFuture, this, executorService);
+        Futures.addCallback(workerFuture, this);
       }
     }
 
index e98fa8269621a0ae0bc385cd50b6b58b73c5e25c..710ec5b0e870fabc9069a4d3cac63104beb758ce 100644 (file)
@@ -230,7 +230,7 @@ public class CeProcessingSchedulerImplTest {
     for (int i = 0; i < workerCount; i++) {
       verify(processingExecutorService).schedule(workers[i], ceConfiguration.getQueuePollingDelay(), MILLISECONDS);
     }
-    verify(listenableScheduledFuture, times(workerCount)).addListener(any(Runnable.class), eq(processingExecutorService));
+    verify(listenableScheduledFuture, times(workerCount)).addListener(any(Runnable.class), eq(MoreExecutors.directExecutor()));
     for (int i = 0; i < workerCount; i++) {
       verify(ceWorkerFactory).create(i);
     }