diff options
5 files changed, 56 insertions, 50 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/ComputationThreadLauncher.java b/server/sonar-server/src/main/java/org/sonar/server/computation/ComputationThreadLauncher.java index 18bf2a35633..c91d3c88fef 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/ComputationThreadLauncher.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/ComputationThreadLauncher.java @@ -23,7 +23,6 @@ package org.sonar.server.computation; import com.google.common.annotations.VisibleForTesting; import com.google.common.util.concurrent.ThreadFactoryBuilder; import org.picocontainer.Startable; -import org.sonar.api.ServerComponent; import org.sonar.api.platform.Server; import org.sonar.api.platform.ServerStartHandler; @@ -32,7 +31,7 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; -public class ComputationThreadLauncher implements Startable, ServerComponent, ServerStartHandler { +public class ComputationThreadLauncher implements Startable, ServerStartHandler { public static final String THREAD_NAME_PREFIX = "computation-"; diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/BulkIndexer.java b/server/sonar-server/src/main/java/org/sonar/server/es/BulkIndexer.java index c10ad36fe33..aaf7c746f40 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/es/BulkIndexer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/es/BulkIndexer.java @@ -218,28 +218,36 @@ public class BulkIndexer implements Startable { final BulkRequestBuilder req = this.bulkRequest; this.bulkRequest = client.prepareBulk().setRefresh(false); semaphore.acquireUninterruptibly(); - req.execute(new ActionListener<BulkResponse>() { - @Override - public void onResponse(BulkResponse response) { - semaphore.release(); - counter.addAndGet(response.getItems().length); - - for (BulkItemResponse item : response.getItems()) { - if (item.isFailed()) { - StringBuilder sb = new StringBuilder(); - String msg = sb - .append("index [").append(item.getIndex()).append("], type [").append(item.getType()).append("], id [").append(item.getId()) - .append("], message [").append(item.getFailureMessage()).append("]").toString(); - LOGGER.error(msg); - } + req.execute(new BulkResponseActionListener(req)); + } + + private class BulkResponseActionListener implements ActionListener<BulkResponse> { + private final BulkRequestBuilder req; + + public BulkResponseActionListener(BulkRequestBuilder req) { + this.req = req; + } + + @Override + public void onResponse(BulkResponse response) { + semaphore.release(); + counter.addAndGet(response.getItems().length); + + for (BulkItemResponse item : response.getItems()) { + if (item.isFailed()) { + StringBuilder sb = new StringBuilder(); + String msg = sb + .append("index [").append(item.getIndex()).append("], type [").append(item.getType()).append("], id [").append(item.getId()) + .append("], message [").append(item.getFailureMessage()).append("]").toString(); + LOGGER.error(msg); } } + } - @Override - public void onFailure(Throwable e) { - semaphore.release(); - LOGGER.error("Fail to execute bulk index request: " + req, e); - } - }); + @Override + public void onFailure(Throwable e) { + semaphore.release(); + LOGGER.error("Fail to execute bulk index request: " + req, e); + } } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileFactory.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileFactory.java index f4ccf0a162d..ccc8f8f2d52 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileFactory.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileFactory.java @@ -208,7 +208,6 @@ public class QProfileFactory implements ServerComponent { if (db.qualityProfileDao().getByNameAndLanguage(newName, profile.getLanguage(), dbSession) != null) { throw new BadRequestException("Quality profile already exists: " + newName); } - String previousName = profile.getName(); profile.setName(newName); db.qualityProfileDao().update(dbSession, profile); dbSession.commit(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java index 757334f7100..030d81cd45f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java @@ -269,31 +269,33 @@ public class RuleActivator implements ServerComponent { private ActiveRuleDto doUpdate(ActiveRuleChange change, RuleActivatorContext context, DbSession dbSession) { ActiveRuleDao dao = db.activeRuleDao(); ActiveRuleDto activeRule = context.activeRule(); - String severity = change.getSeverity(); - if (severity != null) { - activeRule.setSeverity(severity); - } - ActiveRule.Inheritance inheritance = change.getInheritance(); - if (inheritance != null) { - activeRule.setInheritance(inheritance.name()); - } - dao.update(dbSession, activeRule); - - for (Map.Entry<String, String> param : change.getParameters().entrySet()) { - ActiveRuleParamDto activeRuleParamDto = context.activeRuleParamsAsMap().get(param.getKey()); - if (activeRuleParamDto == null) { - // did not exist - if (param.getValue() != null) { - activeRuleParamDto = ActiveRuleParamDto.createFor(context.ruleParamsByKeys().get(param.getKey())); - activeRuleParamDto.setValue(param.getValue()); - dao.addParam(dbSession, activeRule, activeRuleParamDto); - } - } else { - if (param.getValue() != null) { - activeRuleParamDto.setValue(param.getValue()); - dao.updateParam(dbSession, activeRule, activeRuleParamDto); + if (activeRule != null) { + String severity = change.getSeverity(); + if (severity != null) { + activeRule.setSeverity(severity); + } + ActiveRule.Inheritance inheritance = change.getInheritance(); + if (inheritance != null) { + activeRule.setInheritance(inheritance.name()); + } + dao.update(dbSession, activeRule); + + for (Map.Entry<String, String> param : change.getParameters().entrySet()) { + ActiveRuleParamDto activeRuleParamDto = context.activeRuleParamsAsMap().get(param.getKey()); + if (activeRuleParamDto == null) { + // did not exist + if (param.getValue() != null) { + activeRuleParamDto = ActiveRuleParamDto.createFor(context.ruleParamsByKeys().get(param.getKey())); + activeRuleParamDto.setValue(param.getValue()); + dao.addParam(dbSession, activeRule, activeRuleParamDto); + } } else { - dao.deleteParam(dbSession, activeRule, activeRuleParamDto); + if (param.getValue() != null) { + activeRuleParamDto.setValue(param.getValue()); + dao.updateParam(dbSession, activeRule, activeRuleParamDto); + } else { + dao.deleteParam(dbSession, activeRule, activeRuleParamDto); + } } } } diff --git a/sonar-core/src/main/java/org/sonar/core/component/ScanPerspectives.java b/sonar-core/src/main/java/org/sonar/core/component/ScanPerspectives.java index 778a9c0d7e7..09cf4c72b54 100644 --- a/sonar-core/src/main/java/org/sonar/core/component/ScanPerspectives.java +++ b/sonar-core/src/main/java/org/sonar/core/component/ScanPerspectives.java @@ -20,7 +20,6 @@ package org.sonar.core.component; import com.google.common.collect.Maps; -import org.sonar.api.BatchComponent; import org.sonar.api.batch.SonarIndex; import org.sonar.api.batch.fs.InputDir; import org.sonar.api.batch.fs.InputFile; @@ -33,10 +32,9 @@ import org.sonar.api.resources.File; import org.sonar.api.resources.Resource; import javax.annotation.CheckForNull; - import java.util.Map; -public class ScanPerspectives implements ResourcePerspectives, BatchComponent { +public class ScanPerspectives implements ResourcePerspectives { private final Map<Class<?>, PerspectiveBuilder<?>> builders = Maps.newHashMap(); private final SonarIndex resourceIndex; |