]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5007 - Fixed DB session in RuleActivator and RegisterQProfile
authorStephane Gamard <stephane.gamard@searchbox.com>
Thu, 12 Jun 2014 18:05:40 +0000 (20:05 +0200)
committerStephane Gamard <stephane.gamard@searchbox.com>
Thu, 12 Jun 2014 18:05:40 +0000 (20:05 +0200)
sonar-server/src/main/java/org/sonar/server/qualityprofile/RegisterQualityProfiles.java
sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java

index 3f8f6c755ce7b9c6472659f57e003eacb9007b0a..e6508b1709159afb7dd1afd7565cea087d0a3255 100644 (file)
@@ -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<RulesProfile> profileDefs, DbSession session) {
index cf2cf6fc0f3fac862c5d4b5f32af84b12de86ccf..4e0cd7c9aa818d8cc7984a1e0cf731259f4e56a3 100644 (file)
@@ -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();
     }