diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-05-10 12:03:32 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-05-10 12:03:44 +0200 |
commit | af746806513116025cfea334ad2debfa0f5c34e2 (patch) | |
tree | 2513f435b22007630d37bb1b3ce65fe088790348 | |
parent | 3254f4804263e94f81d696e717322c1460d5b737 (diff) | |
download | sonarqube-af746806513116025cfea334ad2debfa0f5c34e2.tar.gz sonarqube-af746806513116025cfea334ad2debfa0f5c34e2.zip |
SONAR-7594 fix indexing of component names > 400 characters
-rw-r--r-- | sonar-db/src/main/java/org/sonar/db/component/ResourceIndexDao.java | 2 | ||||
-rw-r--r-- | sonar-db/src/test/java/org/sonar/db/component/ResourceIndexDaoTest.java | 2 |
2 files changed, 2 insertions, 2 deletions
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)); |