]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-12146 fix resilience of deletion of project/branch/view
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Mon, 10 Jun 2019 13:48:47 +0000 (15:48 +0200)
committerSonarTech <sonartech@sonarsource.com>
Thu, 13 Jun 2019 18:21:12 +0000 (20:21 +0200)
server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java

index d765b932defa3af1af676861a55fbc392c9cce0b..1f0c55ff2b0e02d982b53b501efa0e7a83e5a710 100644 (file)
@@ -245,28 +245,28 @@ public class PurgeDao implements Dao {
     deleteRootComponent(uuid, purgeMapper, purgeCommands);
   }
 
-  private void deleteRootComponent(String rootUuid, PurgeMapper mapper, PurgeCommands commands) {
+  private static void deleteRootComponent(String rootUuid, PurgeMapper mapper, PurgeCommands commands) {
     List<IdUuidPair> rootAndModulesOrSubviews = mapper.selectRootAndModulesOrSubviewsByProjectUuid(rootUuid);
     long rootId = rootAndModulesOrSubviews.stream()
       .filter(pair -> pair.getUuid().equals(rootUuid))
       .map(IdUuidPair::getId)
       .findFirst()
       .orElseThrow(() -> new IllegalArgumentException("Couldn't find root component with uuid " + rootUuid));
-    commands.deletePermissions(rootId);
     commands.deleteLinks(rootUuid);
     commands.deleteAnalyses(rootUuid);
     commands.deleteByRootAndModulesOrSubviews(rootAndModulesOrSubviews);
-    commands.deleteComponents(rootUuid);
     commands.deleteIssues(rootUuid);
     commands.deleteFileSources(rootUuid);
     commands.deleteCeActivity(rootUuid);
     commands.deleteCeQueue(rootUuid);
     commands.deleteWebhooks(rootUuid);
     commands.deleteWebhookDeliveries(rootUuid);
+    commands.deleteLiveMeasures(rootUuid);
     commands.deleteProjectMappings(rootUuid);
     commands.deleteProjectAlmBindings(rootUuid);
+    commands.deletePermissions(rootId);
     commands.deleteBranch(rootUuid);
-    commands.deleteLiveMeasures(rootUuid);
+    commands.deleteComponents(rootUuid);
   }
 
   /**