]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2536 Execution of FindBugs should not leave unterminated threads
authorEvgeny Mandrikov <mandrikov@gmail.com>
Mon, 20 Jun 2011 20:55:43 +0000 (00:55 +0400)
committerEvgeny Mandrikov <mandrikov@gmail.com>
Tue, 21 Jun 2011 09:11:24 +0000 (13:11 +0400)
plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsExecutor.java

index 3fed8b0a219c30e94b78c86c7063afe615f125fa..e1e8fd2a4820f920e2877dbfe8ba988f1044f447 100644 (file)
@@ -29,6 +29,7 @@ import java.util.Enumeration;
 import java.util.List;
 import java.util.concurrent.Callable;
 import java.util.concurrent.Executors;
+import java.util.concurrent.ExecutorService;
 import java.util.concurrent.TimeUnit;
 
 import com.google.common.collect.Lists;
@@ -64,6 +65,7 @@ public class FindbugsExecutor implements BatchExtension {
     Thread.currentThread().setContextClassLoader(FindBugs2.class.getClassLoader());
 
     OutputStream xmlOutput = null;
+    ExecutorService executorService = Executors.newSingleThreadExecutor();
     try {
       DetectorFactoryCollection detectorFactory = loadFindbugsPlugins();
 
@@ -99,7 +101,7 @@ public class FindbugsExecutor implements BatchExtension {
 
       engine.finishSettings();
 
-      Executors.newSingleThreadExecutor().submit(new FindbugsTask(engine)).get(configuration.getTimeout(), TimeUnit.MILLISECONDS);
+      executorService.submit(new FindbugsTask(engine)).get(configuration.getTimeout(), TimeUnit.MILLISECONDS);
 
       profiler.stop();
 
@@ -109,6 +111,7 @@ public class FindbugsExecutor implements BatchExtension {
     } catch (Exception e) {
       throw new SonarException("Can not execute Findbugs", e);
     } finally {
+      executorService.shutdown();
       IOUtils.closeQuietly(xmlOutput);
       Thread.currentThread().setContextClassLoader(initialClassLoader);
     }