From acece2f60c15f68598298c56f41a7e64e792f6f2 Mon Sep 17 00:00:00 2001 From: Stephane Gamard Date: Thu, 12 Jun 2014 20:05:40 +0200 Subject: [PATCH] SONAR-5007 - Fixed DB session in RuleActivator and RegisterQProfile --- .../server/qualityprofile/RegisterQualityProfiles.java | 6 ++---- .../org/sonar/server/qualityprofile/RuleActivator.java | 10 +++++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/RegisterQualityProfiles.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/RegisterQualityProfiles.java index 3f8f6c755ce..e6508b17091 100644 --- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/RegisterQualityProfiles.java +++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/RegisterQualityProfiles.java @@ -102,9 +102,9 @@ public class RegisterQualityProfiles implements ServerComponent { register(profileKey, entry.getValue(), session); } builtInProfiles.put(language, profileName); - } + } setDefault(language, profileDefs, session); - } + } session.commit(); } finally { session.close(); @@ -151,13 +151,11 @@ public class RegisterQualityProfiles implements ServerComponent { private void cleanUp(QualityProfileKey key, QualityProfileDto profileDto, DbSession session) { dbClient.activeRuleDao().deleteByProfileKey(session, key); dbClient.qualityProfileDao().delete(session, profileDto); - session.commit(); } private void insertNewProfile(QualityProfileKey key, DbSession session) { QualityProfileDto profile = QualityProfileDto.createFor(key); dbClient.qualityProfileDao().insert(session, profile); - session.commit(); } private void setDefault(String language, List profileDefs, DbSession session) { diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java index cf2cf6fc0f3..4e0cd7c9aa8 100644 --- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java +++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java @@ -30,7 +30,11 @@ import org.sonar.api.server.rule.RuleParamType; import org.sonar.core.log.Log; import org.sonar.core.persistence.DbSession; import org.sonar.core.preview.PreviewCache; -import org.sonar.core.qualityprofile.db.*; +import org.sonar.core.qualityprofile.db.ActiveRuleDto; +import org.sonar.core.qualityprofile.db.ActiveRuleKey; +import org.sonar.core.qualityprofile.db.ActiveRuleParamDto; +import org.sonar.core.qualityprofile.db.QualityProfileDto; +import org.sonar.core.qualityprofile.db.QualityProfileKey; import org.sonar.core.rule.RuleDto; import org.sonar.core.rule.RuleParamDto; import org.sonar.server.db.DbClient; @@ -47,7 +51,6 @@ import org.sonar.server.search.QueryOptions; import org.sonar.server.util.TypeValidations; import javax.annotation.Nullable; - import java.util.Iterator; import java.util.List; import java.util.Map; @@ -145,7 +148,6 @@ public class RuleActivator implements ServerComponent { if (!changes.isEmpty()) { log.write(dbSession, Log.Type.ACTIVE_RULE, changes); - dbSession.commit(); previewCache.reportGlobalModification(); } return changes; @@ -282,7 +284,6 @@ public class RuleActivator implements ServerComponent { for (ActiveRuleDto activeRule : activeRules) { changes.addAll(deactivate(dbSession, activeRule.getKey(), true)); } - dbSession.commit(); return changes; } @@ -317,7 +318,6 @@ public class RuleActivator implements ServerComponent { if (!changes.isEmpty()) { log.write(dbSession, Log.Type.ACTIVE_RULE, changes); - dbSession.commit(); previewCache.reportGlobalModification(); } -- 2.39.5