diff options
author | Eric Hartmann <hartmann.eric@gmail.com> | 2018-01-29 16:17:39 +0100 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2018-02-08 13:41:00 +0100 |
commit | 213d3957ef79ff787d2485e72afe1927ad1c50b9 (patch) | |
tree | 93df59c2c05ab5e47b203125f41111232aa2a8bd /server | |
parent | 953dac0d23007567472414c35ed97861f207e779 (diff) | |
download | sonarqube-213d3957ef79ff787d2485e72afe1927ad1c50b9.tar.gz sonarqube-213d3957ef79ff787d2485e72afe1927ad1c50b9.zip |
SONAR-10313 Do not request DB when list is empty
Diffstat (limited to 'server')
-rw-r--r-- | server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleDao.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleDao.java index 7989e98e3b8..96d540e8579 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleDao.java @@ -34,6 +34,7 @@ import org.sonar.db.es.RuleExtensionId; import org.sonar.db.organization.OrganizationDto; import static com.google.common.base.Preconditions.checkNotNull; +import static java.util.Collections.emptyList; import static java.util.Optional.ofNullable; import static org.sonar.db.DatabaseUtils.executeLargeInputs; import static org.sonar.db.DatabaseUtils.executeLargeInputsWithoutOutput; @@ -82,26 +83,41 @@ public class RuleDao implements Dao { } public List<RuleDto> selectByIds(DbSession session, String organizationUuid, List<Integer> ids) { + if (ids.isEmpty()) { + return emptyList(); + } return ensureOrganizationIsSet( organizationUuid, executeLargeInputs(ids, chunk -> mapper(session).selectByIds(organizationUuid, chunk))); } public List<RuleDefinitionDto> selectDefinitionByIds(DbSession session, Collection<Integer> ids) { + if (ids.isEmpty()) { + return emptyList(); + } return executeLargeInputs(ids, mapper(session)::selectDefinitionByIds); } public List<RuleDto> selectByKeys(DbSession session, OrganizationDto organization, Collection<RuleKey> keys) { + if (keys.isEmpty()) { + return emptyList(); + } return ensureOrganizationIsSet(organization.getUuid(), executeLargeInputs(keys, chunk -> mapper(session).selectByKeys(organization.getUuid(), chunk))); } public List<RuleDto> selectByKeys(DbSession session, String organizationUuid, Collection<RuleKey> keys) { + if (keys.isEmpty()) { + return emptyList(); + } return ensureOrganizationIsSet(organizationUuid, executeLargeInputs(keys, chunk -> mapper(session).selectByKeys(organizationUuid, chunk))); } public List<RuleDefinitionDto> selectDefinitionByKeys(DbSession session, Collection<RuleKey> keys) { + if (keys.isEmpty()) { + return emptyList(); + } return executeLargeInputs(keys, mapper(session)::selectDefinitionByKeys); } |