]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7594 fix indexing of component names > 400 characters
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 10 May 2016 10:03:32 +0000 (12:03 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 10 May 2016 10:03:44 +0000 (12:03 +0200)
sonar-db/src/main/java/org/sonar/db/component/ResourceIndexDao.java
sonar-db/src/test/java/org/sonar/db/component/ResourceIndexDaoTest.java

index 58bcac6ead65c6ba20aa49b3c28b6d49c1e1b328..74c67181f528100863adbbb9d31e85b89be534c2 100644 (file)
@@ -202,7 +202,7 @@ public class ResourceIndexDao extends AbstractDao {
     int maxPosition = key.length() == SINGLE_INDEX_SIZE ? 0 : key.length() - MINIMUM_KEY_SIZE;
     for (int position = 0; position <= maxPosition; position++) {
       dto.setPosition(position);
-      dto.setKey(substring(key, position, MAXIMUM_KEY_SIZE));
+      dto.setKey(substring(key, position, position + MAXIMUM_KEY_SIZE));
       mapper.insert(dto);
     }
   }
index d54e39fa7b791f82a8bf556a55fe4a2c38cffba0..092b7ba651a8a2f1bee9d9e8e169b03c9048b0f0 100644 (file)
@@ -158,7 +158,7 @@ public class ResourceIndexDaoTest {
   @Test
   public void restrict_indexed_combinations_to_400_characters() {
     String longName = repeat("a", 2_000);
-    ComponentDto project = new ComponentDto().setId(1L).setKey("the_key").setName(longName).setScope(Scopes.PROJECT).setQualifier(Qualifiers.PROJECT);
+    ComponentDto project = new ComponentDto().setKey("the_key").setName(longName).setScope(Scopes.PROJECT).setQualifier(Qualifiers.PROJECT);
     DbSession session = dbTester.getSession();
     dbTester.getDbClient().componentDao().insert(session, project);
     dbTester.getDbClient().snapshotDao().insert(session, new SnapshotDto().setComponentId(project.getId()).setRootProjectId(project.getId()).setLast(true));