From: Simon Brandhof Date: Tue, 10 May 2016 10:03:32 +0000 (+0200) Subject: SONAR-7594 fix indexing of component names > 400 characters X-Git-Tag: 5.6-RC1~186 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=af746806513116025cfea334ad2debfa0f5c34e2;p=sonarqube.git SONAR-7594 fix indexing of component names > 400 characters --- diff --git a/sonar-db/src/main/java/org/sonar/db/component/ResourceIndexDao.java b/sonar-db/src/main/java/org/sonar/db/component/ResourceIndexDao.java index 58bcac6ead6..74c67181f52 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/ResourceIndexDao.java +++ b/sonar-db/src/main/java/org/sonar/db/component/ResourceIndexDao.java @@ -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); } } diff --git a/sonar-db/src/test/java/org/sonar/db/component/ResourceIndexDaoTest.java b/sonar-db/src/test/java/org/sonar/db/component/ResourceIndexDaoTest.java index d54e39fa7b7..092b7ba651a 100644 --- a/sonar-db/src/test/java/org/sonar/db/component/ResourceIndexDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/component/ResourceIndexDaoTest.java @@ -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));