if (path == null) {
LoggerFactory.getLogger(getClass()).warn(String.format("File '%s' is not in basedir '%s'", file.getAbsolutePath(), fileSystem.baseDir()));
} else {
- InputFile input = newInputFile(fileSystem, sourceDir, type, file, path);
- if (input != null && accept(input)) {
- cache.put(fileSystem.moduleKey(), input);
- status.markAsIndexed(path);
- }
+ InputFile input = newInputFile(fileSystem, sourceDir, type, file, path);
+ if (input != null && accept(input)) {
+ cache.put(fileSystem.moduleKey(), input);
+ status.markAsIndexed(path);
}
+ }
}
@CheckForNull
private InputFile newInputFile(ModuleFileSystem fileSystem, File sourceDir, String type, File file, String path) {
String lang = languageRecognizer.of(file);
- if (lang==null) {
+ if (lang == null) {
return null;
}
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
-import org.sonar.api.resources.Java;
import org.sonar.api.resources.JavaFile;
import org.sonar.api.resources.JavaPackage;
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 {
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();
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 {
for (Future result : results) {
result.get();
}
+ } catch (Exception e) {
+ throw new IllegalStateException("Fail to start migration threads", e);
} finally {
progress.cancel();
timer.cancel();
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;
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");
}
}