From: Simon Brandhof Date: Wed, 5 Feb 2014 14:22:05 +0000 (+0100) Subject: SONAR-926 deterministic error message in ResourceKeyMigration X-Git-Tag: 4.2~245 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a7b80c4e8833473a583adfa514245223091e5505;p=sonarqube.git SONAR-926 deterministic error message in ResourceKeyMigration --- diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java b/sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java index bb3e2a60d3a..ded2cfed686 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java @@ -31,9 +31,9 @@ import org.sonar.api.scan.filesystem.InputFile; import org.sonar.api.scan.filesystem.internal.DefaultInputFile; import org.sonar.api.utils.PathUtils; +import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.TreeMap; public class ResourceKeyMigration implements BatchComponent { @@ -63,9 +63,9 @@ public class ResourceKeyMigration implements BatchComponent { public void migrateIfNeeded(Project module, Iterable inputFiles) { if (migrationNeeded) { logger.info("Starting migration of resource keys"); - Map deprecatedFileKeyMapper = new TreeMap(); - Map deprecatedTestKeyMapper = new TreeMap(); - Map deprecatedDirectoryKeyMapper = new TreeMap(); + Map deprecatedFileKeyMapper = new HashMap(); + Map deprecatedTestKeyMapper = new HashMap(); + Map deprecatedDirectoryKeyMapper = new HashMap(); for (InputFile inputFile : inputFiles) { String deprecatedKey = inputFile.attribute(DefaultInputFile.ATTRIBUTE_COMPONENT_DEPRECATED_KEY); if (deprecatedKey != null) { @@ -93,7 +93,7 @@ public class ResourceKeyMigration implements BatchComponent { .append(ResourceModel.class.getSimpleName()) .append(" where enabled = true ") .append(" and rootId = :rootId ") - .append(" and scope = '").append(Scopes.FILE).append("'"); + .append(" and scope = '").append(Scopes.FILE).append("' order by key"); List resources = session.createQuery(hql.toString()).setParameter("rootId", moduleId).getResultList(); for (ResourceModel resourceModel : resources) { String oldEffectiveKey = resourceModel.getKey(); diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java index 47bee815c48..380f7ca026b 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java @@ -25,15 +25,9 @@ import com.google.common.io.Files; import org.apache.commons.lang.StringUtils; import org.sonar.api.BatchComponent; import org.sonar.api.CoreProperties; -import org.sonar.api.batch.InstantiationStrategy; import org.sonar.api.batch.SonarIndex; import org.sonar.api.config.Settings; -import org.sonar.api.resources.File; -import org.sonar.api.resources.Java; -import org.sonar.api.resources.JavaFile; -import org.sonar.api.resources.Languages; -import org.sonar.api.resources.Project; -import org.sonar.api.resources.Resource; +import org.sonar.api.resources.*; import org.sonar.api.scan.filesystem.FileQuery; import org.sonar.api.scan.filesystem.InputFile; import org.sonar.api.scan.filesystem.internal.DefaultInputFile; @@ -47,7 +41,6 @@ import org.sonar.core.resource.ResourceDto; * Index all files/directories of the module in SQ database and importing source code. * @since 4.2 */ -@InstantiationStrategy(InstantiationStrategy.PER_PROJECT) public class ComponentIndexer implements BatchComponent { private final Languages languages;