]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7330 Fix indexation of debt model reset
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 1 Mar 2016 16:47:16 +0000 (17:47 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 1 Mar 2016 16:47:16 +0000 (17:47 +0100)
server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java

index 997fb701a8fda6bf621aff539ceace2d7cdda005..ad69b0639a4078ae57c1b223b223d6cfdd5f1d68 100644 (file)
@@ -108,7 +108,7 @@ public class DebtModelBackup {
   public void reset() {
     checkPermission();
 
-    Date updateDate = new Date(system2.now());
+    long updateDate = system2.now();
     DbSession session = dbClient.openSession(false);
     try {
       // Restore rules
@@ -125,14 +125,14 @@ public class DebtModelBackup {
         resetRules(ruleDtos, rules, updateDate, session);
       }
 
-      ruleIndexer.index();
       session.commit();
+      ruleIndexer.index();
     } finally {
       MyBatis.closeQuietly(session);
     }
   }
 
-  private void resetRules(List<RuleDto> ruleDtos, List<RulesDefinition.Rule> rules, Date updateDate, DbSession session) {
+  private void resetRules(List<RuleDto> ruleDtos, List<RulesDefinition.Rule> rules, long updateDate, DbSession session) {
     for (RuleDto rule : ruleDtos) {
       // Restore default debt definitions
 
@@ -158,7 +158,7 @@ public class DebtModelBackup {
       rule.setRemediationFunction(null);
       rule.setRemediationCoefficient(null);
       rule.setRemediationOffset(null);
-      rule.setUpdatedAt(updateDate.getTime());
+      rule.setUpdatedAt(updateDate);
       dbClient.ruleDao().update(session, rule);
     }
   }