aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorPierre <pierre.guillot@sonarsource.com>2023-07-06 16:33:40 +0200
committersonartech <sonartech@sonarsource.com>2023-07-17 20:03:45 +0000
commit30b98e2afca3a56f4b52f79f483a3b5ab353ece3 (patch)
treea60a8d3f857e22590e3265741df1174b5c86b3f7 /server
parent76a58bd6272c27cda372e7b0da96404501f2adcb (diff)
downloadsonarqube-30b98e2afca3a56f4b52f79f483a3b5ab353ece3.tar.gz
sonarqube-30b98e2afca3a56f4b52f79f483a3b5ab353ece3.zip
NO-JIRA replace MoreCollectors.toArrayList(size) with Collectors.toList
Diffstat (limited to 'server')
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/es/EsQueueDao.java4
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java3
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/component/index/EntityDefinitionIndexer.java3
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndexer.java7
-rw-r--r--server/sonar-webserver-core/src/it/java/org/sonar/server/webhook/WebhookQGChangeEventListenerIT.java4
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/rule/SingleDeprecatedRuleKeyTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchAction.java11
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java3
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/RuleActivationContext.java4
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/RuleActivator.java5
10 files changed, 24 insertions, 24 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/es/EsQueueDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/es/EsQueueDao.java
index a2ef042e72c..e168e41a621 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/es/EsQueueDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/es/EsQueueDao.java
@@ -22,13 +22,13 @@ package org.sonar.db.es;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
+import java.util.stream.Collectors;
import org.sonar.api.utils.System2;
import org.sonar.core.util.UuidFactory;
import org.sonar.db.Dao;
import org.sonar.db.DbSession;
import static java.util.Collections.singletonList;
-import static org.sonar.core.util.stream.MoreCollectors.toArrayList;
import static org.sonar.db.DatabaseUtils.executeLargeUpdates;
public class EsQueueDao implements Dao {
@@ -65,7 +65,7 @@ public class EsQueueDao implements Dao {
List<String> uuids = items.stream()
.map(EsQueueDto::getUuid)
.filter(Objects::nonNull)
- .collect(toArrayList(items.size()));
+ .collect(Collectors.toList());
executeLargeUpdates(uuids, mapper::delete);
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java
index 4fb7dd38f1c..9f2fbfe680e 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java
@@ -31,7 +31,6 @@ import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.sonar.api.utils.System2;
import org.sonar.core.util.UuidFactory;
-import org.sonar.core.util.stream.MoreCollectors;
import org.sonar.db.Dao;
import org.sonar.db.DatabaseUtils;
import org.sonar.db.DbSession;
@@ -178,7 +177,7 @@ public class QualityProfileDao implements Dao {
}
public List<QProfileDto> selectChildren(DbSession dbSession, Collection<QProfileDto> profiles) {
- List<String> uuids = profiles.stream().map(QProfileDto::getKee).collect(MoreCollectors.toArrayList(profiles.size()));
+ List<String> uuids = profiles.stream().map(QProfileDto::getKee).collect(Collectors.toList());
return DatabaseUtils.executeLargeInputs(uuids, chunk -> mapper(dbSession).selectChildren(chunk));
}
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/component/index/EntityDefinitionIndexer.java b/server/sonar-server-common/src/main/java/org/sonar/server/component/index/EntityDefinitionIndexer.java
index 180eae9230f..983df5b4e2f 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/component/index/EntityDefinitionIndexer.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/component/index/EntityDefinitionIndexer.java
@@ -27,6 +27,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
+import java.util.stream.Collectors;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder;
@@ -123,7 +124,7 @@ public class EntityDefinitionIndexer implements EventIndexer, AnalysisIndexer, N
private static ArrayList<EsQueueDto> createEsQueueDtosFromEntities(Collection<String> entityUuids) {
return entityUuids.stream()
.map(entityUuid -> EsQueueDto.create(TYPE_COMPONENT.format(), entityUuid, null, entityUuid))
- .collect(MoreCollectors.toArrayList(entityUuids.size()));
+ .collect(Collectors.toList());
}
@Override
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndexer.java b/server/sonar-server-common/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndexer.java
index 9bf34083166..bb47c1e673b 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndexer.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndexer.java
@@ -30,7 +30,6 @@ import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.sonar.api.resources.Qualifiers;
-import org.sonar.core.util.stream.MoreCollectors;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.component.BranchDto;
@@ -130,14 +129,14 @@ public class ProjectMeasuresIndexer implements EventIndexer, AnalysisIndexer, Ne
private Collection<EsQueueDto> prepareForRecovery(DbSession dbSession, Collection<String> entityUuids) {
List<EsQueueDto> items = entityUuids.stream()
.map(entityUuid -> EsQueueDto.create(TYPE_PROJECT_MEASURES.format(), entityUuid, null, entityUuid))
- .collect(MoreCollectors.toArrayList(entityUuids.size()));
+ .collect(Collectors.toList());
return dbClient.esQueueDao().insert(dbSession, items);
}
public IndexingResult commitAndIndex(DbSession dbSession, Collection<String> projectUuids) {
List<EsQueueDto> items = projectUuids.stream()
.map(projectUuid -> EsQueueDto.create(TYPE_PROJECT_MEASURES.format(), projectUuid, null, projectUuid))
- .collect(MoreCollectors.toArrayList(projectUuids.size()));
+ .collect(Collectors.toList());
dbClient.esQueueDao().insert(dbSession, items);
dbSession.commit();
@@ -154,7 +153,7 @@ public class ProjectMeasuresIndexer implements EventIndexer, AnalysisIndexer, Ne
BulkIndexer bulkIndexer = createBulkIndexer(Size.REGULAR, listener);
bulkIndexer.start();
- List<String> projectUuids = items.stream().map(EsQueueDto::getDocId).collect(MoreCollectors.toArrayList(items.size()));
+ List<String> projectUuids = items.stream().map(EsQueueDto::getDocId).collect(Collectors.toList());
Iterator<String> it = projectUuids.iterator();
while (it.hasNext()) {
String projectUuid = it.next();
diff --git a/server/sonar-webserver-core/src/it/java/org/sonar/server/webhook/WebhookQGChangeEventListenerIT.java b/server/sonar-webserver-core/src/it/java/org/sonar/server/webhook/WebhookQGChangeEventListenerIT.java
index 72ece76b976..37c34c09936 100644
--- a/server/sonar-webserver-core/src/it/java/org/sonar/server/webhook/WebhookQGChangeEventListenerIT.java
+++ b/server/sonar-webserver-core/src/it/java/org/sonar/server/webhook/WebhookQGChangeEventListenerIT.java
@@ -29,6 +29,7 @@ import java.util.Optional;
import java.util.Random;
import java.util.Set;
import java.util.function.Supplier;
+import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
@@ -63,7 +64,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;
-import static org.sonar.core.util.stream.MoreCollectors.toArrayList;
import static org.sonar.db.component.BranchType.BRANCH;
@RunWith(DataProviderRunner.class)
@@ -239,7 +239,7 @@ public class WebhookQGChangeEventListenerIT {
.setAnalysisUuid(snapshotUuid)
.setKey(entry.getKey())
.setValue(entry.getValue()))
- .collect(toArrayList(properties.size()));
+ .collect(Collectors.toList());
dbTester.getDbClient().analysisPropertiesDao().insert(dbTester.getSession(), analysisProperties);
dbTester.getSession().commit();
}
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/SingleDeprecatedRuleKeyTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/SingleDeprecatedRuleKeyTest.java
index d5a4b3b528c..c429d743a11 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/SingleDeprecatedRuleKeyTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/SingleDeprecatedRuleKeyTest.java
@@ -21,11 +21,11 @@ package org.sonar.server.rule;
import com.google.common.collect.ImmutableSet;
import java.util.Set;
+import java.util.stream.Collectors;
import org.assertj.core.groups.Tuple;
import org.junit.Test;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.server.rule.RulesDefinition;
-import org.sonar.core.util.stream.MoreCollectors;
import org.sonar.db.rule.DeprecatedRuleKeyDto;
import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
@@ -81,7 +81,7 @@ public class SingleDeprecatedRuleKeyTest {
.containsExactlyInAnyOrder(
deprecatedRuleKeys.stream().map(
r -> tuple(null, r.repository(), r.rule(), rule.repository().key(), rule.key(), RuleKey.of(r.repository(), r.rule())))
- .collect(MoreCollectors.toArrayList(deprecatedRuleKeys.size())).toArray(new Tuple[deprecatedRuleKeys.size()]));
+ .collect(Collectors.toList()).toArray(new Tuple[deprecatedRuleKeys.size()]));
}
@Test
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchAction.java
index 8ddcebeb000..c12773a7e98 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchAction.java
@@ -32,7 +32,6 @@ import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
import org.sonar.api.web.UserRole;
-import org.sonar.core.util.stream.MoreCollectors;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.component.ComponentDto;
@@ -51,14 +50,14 @@ import static org.sonar.api.resources.Qualifiers.APP;
import static org.sonar.api.resources.Qualifiers.PROJECT;
import static org.sonar.api.resources.Qualifiers.SUBVIEW;
import static org.sonar.api.resources.Qualifiers.VIEW;
+import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRIC_KEYS;
+import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_PROJECT_KEYS;
+import static org.sonar.server.exceptions.BadRequestException.checkRequest;
import static org.sonar.server.measure.ws.MeasureDtoToWsMeasure.updateMeasureBuilder;
import static org.sonar.server.measure.ws.MeasuresWsParametersBuilder.createMetricKeysParameter;
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_002;
-import static org.sonar.server.exceptions.BadRequestException.checkRequest;
import static org.sonar.server.ws.WsUtils.writeProtobuf;
-import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRIC_KEYS;
-import static org.sonar.server.component.ws.MeasuresWsParameters.PARAM_PROJECT_KEYS;
public class SearchAction implements MeasuresWsAction {
@@ -170,8 +169,8 @@ public class SearchAction implements MeasuresWsAction {
private List<LiveMeasureDto> searchMeasures() {
return dbClient.liveMeasureDao().selectByComponentUuidsAndMetricUuids(dbSession,
- projects.stream().map(ComponentDto::uuid).collect(MoreCollectors.toArrayList(projects.size())),
- metrics.stream().map(MetricDto::getUuid).collect(MoreCollectors.toArrayList(metrics.size())));
+ projects.stream().map(ComponentDto::uuid).collect(Collectors.toList()),
+ metrics.stream().map(MetricDto::getUuid).collect(Collectors.toList()));
}
private SearchWsResponse buildResponse() {
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java
index 2afd72de35c..8091e6819af 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java
@@ -31,6 +31,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
+import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
@@ -171,7 +172,7 @@ public class QProfileExporters {
List<RuleActivation> activations = activeRules.stream()
.map(activeRule -> toRuleActivation(activeRule, rulesByRuleKey))
.filter(Objects::nonNull)
- .collect(MoreCollectors.toArrayList(activeRules.size()));
+ .collect(Collectors.toList());
return qProfileRules.activateAndCommit(dbSession, profile, activations);
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/RuleActivationContext.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/RuleActivationContext.java
index 6776d52841b..e7a8138d897 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/RuleActivationContext.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/RuleActivationContext.java
@@ -25,6 +25,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
+import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import org.sonar.api.rule.RuleKey;
import org.sonar.db.qualityprofile.ActiveRuleDto;
@@ -40,7 +41,6 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import static java.util.Objects.requireNonNull;
import static org.sonar.core.util.stream.MoreCollectors.index;
-import static org.sonar.core.util.stream.MoreCollectors.toArrayList;
import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex;
import static org.sonar.server.exceptions.BadRequestException.checkRequest;
@@ -194,7 +194,7 @@ public class RuleActivationContext {
}
Collection<QProfileDto> baseProfiles = profilesByUuid.values().stream()
.filter(p -> p.getRulesProfileUuid().equals(baseRulesProfile.getUuid()))
- .collect(toArrayList(profilesByUuid.size()));
+ .collect(Collectors.toList());
DescendantProfilesSupplier.Result result = descendantProfilesSupplier.get(baseProfiles, rulesByUuid.keySet());
register(result.profiles());
register(result.activeRules(), result.activeRuleParams());
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/RuleActivator.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/RuleActivator.java
index 568efa6db82..d2e05d66a6f 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/RuleActivator.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/RuleActivator.java
@@ -26,6 +26,7 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
@@ -476,7 +477,7 @@ public class RuleActivator {
.map(QProfileDto::getRulesProfileUuid)
.collect(MoreCollectors.toHashSet());
Collection<ActiveRuleDto> activeRules = db.activeRuleDao().selectByRulesAndRuleProfileUuids(dbSession, ruleUuids, ruleProfileUuids);
- List<String> activeRuleUuids = activeRules.stream().map(ActiveRuleDto::getUuid).collect(MoreCollectors.toArrayList(activeRules.size()));
+ List<String> activeRuleUuids = activeRules.stream().map(ActiveRuleDto::getUuid).collect(Collectors.toList());
List<ActiveRuleParamDto> activeRuleParams = db.activeRuleDao().selectParamsByActiveRuleUuids(dbSession, activeRuleUuids);
return new DescendantProfilesSupplier.Result(profiles, activeRules, activeRuleParams);
};
@@ -491,7 +492,7 @@ public class RuleActivator {
private void completeWithActiveRules(DbSession dbSession, RuleActivationContext.Builder builder, Collection<String> ruleUuids, Collection<String> ruleProfileUuids) {
Collection<ActiveRuleDto> activeRules = db.activeRuleDao().selectByRulesAndRuleProfileUuids(dbSession, ruleUuids, ruleProfileUuids);
builder.setActiveRules(activeRules);
- List<String> activeRuleUuids = activeRules.stream().map(ActiveRuleDto::getUuid).collect(MoreCollectors.toArrayList(activeRules.size()));
+ List<String> activeRuleUuids = activeRules.stream().map(ActiveRuleDto::getUuid).collect(Collectors.toList());
builder.setActiveRuleParams(db.activeRuleDao().selectParamsByActiveRuleUuids(dbSession, activeRuleUuids));
}