aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2013-10-21 17:07:40 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2013-10-21 17:07:50 +0200
commit0a67df44a1f04ffd6a4d7d2845b6a1e136519f04 (patch)
tree6ae3d8f5dea847418cd0fb31c99e2cff5ae9b090 /sonar-server
parentcda2773b5ec6b436c2b966ed04147b1dfeab2f67 (diff)
downloadsonarqube-0a67df44a1f04ffd6a4d7d2845b6a1e136519f04.tar.gz
sonarqube-0a67df44a1f04ffd6a4d7d2845b6a1e136519f04.zip
Fix some quality flaws
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/java/org/sonar/server/db/migrations/violation/ViolationConverters.java11
-rw-r--r--sonar-server/src/test/java/org/sonar/server/db/migrations/violation/ViolationConvertersTest.java5
2 files changed, 11 insertions, 5 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/ViolationConverters.java b/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/ViolationConverters.java
index 3115472e1b5..622708d239f 100644
--- a/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/ViolationConverters.java
+++ b/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/ViolationConverters.java
@@ -26,7 +26,10 @@ import org.sonar.core.persistence.Database;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
-import java.util.concurrent.*;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
class ViolationConverters {
@@ -38,7 +41,7 @@ class ViolationConverters {
this.settings = settings;
}
- void execute(Referentials referentials, Database db) throws ExecutionException, InterruptedException {
+ void execute(Referentials referentials, Database db) {
Progress progress = new Progress(referentials.totalViolations());
List<Callable<Object>> converters = Lists.newArrayList();
@@ -49,7 +52,7 @@ class ViolationConverters {
doExecute(progress, converters);
}
- void doExecute(TimerTask progress, List<Callable<Object>> converters) throws InterruptedException, ExecutionException {
+ void doExecute(TimerTask progress, List<Callable<Object>> converters) {
Timer timer = new Timer(Progress.THREAD_NAME);
timer.schedule(progress, Progress.DELAY_MS, Progress.DELAY_MS);
try {
@@ -59,6 +62,8 @@ class ViolationConverters {
for (Future result : results) {
result.get();
}
+ } catch (Exception e) {
+ throw new IllegalStateException("Fail to start migration threads", e);
} finally {
progress.cancel();
timer.cancel();
diff --git a/sonar-server/src/test/java/org/sonar/server/db/migrations/violation/ViolationConvertersTest.java b/sonar-server/src/test/java/org/sonar/server/db/migrations/violation/ViolationConvertersTest.java
index 9b144fe7846..6e37ed949e0 100644
--- a/sonar-server/src/test/java/org/sonar/server/db/migrations/violation/ViolationConvertersTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/db/migrations/violation/ViolationConvertersTest.java
@@ -20,6 +20,7 @@
package org.sonar.server.db.migrations.violation;
import com.google.common.collect.Lists;
+import org.apache.commons.lang.exception.ExceptionUtils;
import org.junit.Test;
import org.sonar.api.config.Settings;
@@ -68,8 +69,8 @@ public class ViolationConvertersTest {
try {
new ViolationConverters(new Settings()).doExecute(new FakeTimerTask(), callables);
fail();
- } catch (ExecutionException e) {
- assertThat(e.getCause().getMessage()).isEqualTo("Need to cry");
+ } catch (Exception e) {
+ assertThat(ExceptionUtils.getRootCause(e).getMessage()).isEqualTo("Need to cry");
}
}