aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre <pierre.guillot@sonarsource.com>2023-07-06 16:18:13 +0200
committersonartech <sonartech@sonarsource.com>2023-07-17 20:03:45 +0000
commit1ade7f5774b98e129d2a79e6adf7450861e5ba9e (patch)
tree7e3c3f403abed0aef6d2d1ed9273bc250601109b
parentb3b0e8a33f1ce672b54e75c7e14e4b708285e64f (diff)
downloadsonarqube-1ade7f5774b98e129d2a79e6adf7450861e5ba9e.tar.gz
sonarqube-1ade7f5774b98e129d2a79e6adf7450861e5ba9e.zip
NO-JIRA replace MoreCollectors.toSet(size) with Collectors.toSet
-rw-r--r--server/sonar-ce-common/src/main/java/org/sonar/ce/queue/CeQueueImpl.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/notification/NotificationFactory.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/notification/ReportAnalysisFailureNotificationHandler.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java3
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/SendIssueNotificationsStep.java3
-rw-r--r--server/sonar-ce/src/main/java/org/sonar/ce/CeDistributedInformationImpl.java3
-rw-r--r--server/sonar-ce/src/main/java/org/sonar/ce/StandaloneCeDistributedInformation.java4
-rw-r--r--server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeWorkerFactoryImpl.java4
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/es/Indexers.java3
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/es/searchrequest/RequestFiltersComputer.java4
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/ChangesOnMyIssueNotificationHandler.java8
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/FPOrWontFixNotificationHandler.java5
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/IssuesChangesNotificationSerializer.java3
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/MyNewIssuesNotificationHandler.java2
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/NewIssuesNotificationHandler.java4
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/notification/NotificationService.java4
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/qualitygate/QualityGate.java4
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/qualitygate/notification/QGChangeNotificationHandler.java4
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexer.java4
-rw-r--r--server/sonar-webserver-auth/src/main/java/org/sonar/server/user/ServerUserSession.java5
-rw-r--r--server/sonar-webserver-core/src/main/java/org/sonar/server/rule/SingleDeprecatedRuleKey.java5
-rw-r--r--server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java3
-rw-r--r--server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java3
-rw-r--r--server/sonar-webserver-es/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java3
-rw-r--r--server/sonar-webserver-webapi/src/it/java/org/sonar/server/project/ws/UpdateVisibilityActionIT.java8
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/TaskFormatter.java5
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ComponentFinder.java4
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SearchProjectsAction.java3
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SuggestionsAction.java6
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/WebIssueStorage.java5
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/BulkChangeAction.java5
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java4
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/ListAction.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/util/stream/MoreCollectors.java5
-rw-r--r--sonar-core/src/test/java/org/sonar/core/util/stream/MoreCollectorsTest.java6
35 files changed, 61 insertions, 85 deletions
diff --git a/server/sonar-ce-common/src/main/java/org/sonar/ce/queue/CeQueueImpl.java b/server/sonar-ce-common/src/main/java/org/sonar/ce/queue/CeQueueImpl.java
index 3ec3c21e114..999236c83df 100644
--- a/server/sonar-ce-common/src/main/java/org/sonar/ce/queue/CeQueueImpl.java
+++ b/server/sonar-ce-common/src/main/java/org/sonar/ce/queue/CeQueueImpl.java
@@ -164,7 +164,7 @@ public class CeQueueImpl implements CeQueue {
.filter(Optional::isPresent)
.map(Optional::get)
.map(CeTaskSubmit.Component::getEntityUuid)
- .collect(MoreCollectors.toSet(submissions.size()));
+ .collect(Collectors.toSet());
if (mainComponentUuids.isEmpty()) {
return t -> true;
}
@@ -236,7 +236,7 @@ public class CeQueueImpl implements CeQueue {
// load characteristics
// TODO could be avoided, characteristics are already present in submissions
- Set<String> taskUuids = dtos.stream().map(CeQueueDto::getUuid).collect(MoreCollectors.toSet(dtos.size()));
+ Set<String> taskUuids = dtos.stream().map(CeQueueDto::getUuid).collect(Collectors.toSet());
Multimap<String, CeTaskCharacteristicDto> characteristicsByTaskUuid = dbClient.ceTaskCharacteristicsDao()
.selectByTaskUuids(dbSession, taskUuids).stream()
.collect(MoreCollectors.index(CeTaskCharacteristicDto::getTaskUuid));
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/notification/NotificationFactory.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/notification/NotificationFactory.java
index a1fdee345f6..481f93f6fb8 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/notification/NotificationFactory.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/notification/NotificationFactory.java
@@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableMap;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
+import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.sonar.api.ce.ComputeEngineSide;
@@ -36,7 +37,6 @@ import org.sonar.ce.task.projectanalysis.component.TreeRootHolder;
import org.sonar.ce.task.projectanalysis.component.TypeAwareVisitorAdapter;
import org.sonar.ce.task.projectanalysis.issue.RuleRepository;
import org.sonar.core.issue.DefaultIssue;
-import org.sonar.core.util.stream.MoreCollectors;
import org.sonar.db.user.UserDto;
import org.sonar.server.issue.notification.IssuesChangesNotification;
import org.sonar.server.issue.notification.IssuesChangesNotificationBuilder;
@@ -94,7 +94,7 @@ public class NotificationFactory {
.setRule(getRuleByRuleKey(issue.ruleKey()))
.setProject(getProject())
.build())
- .collect(MoreCollectors.toSet(issues.size()));
+ .collect(Collectors.toSet());
return issuesChangesSerializer.serialize(new IssuesChangesNotificationBuilder(changedIssues, change));
}
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/notification/ReportAnalysisFailureNotificationHandler.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/notification/ReportAnalysisFailureNotificationHandler.java
index 0387dd532f1..a873748be4f 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/notification/ReportAnalysisFailureNotificationHandler.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/notification/ReportAnalysisFailureNotificationHandler.java
@@ -23,6 +23,7 @@ import com.google.common.collect.Multimap;
import java.util.Collection;
import java.util.Optional;
import java.util.Set;
+import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.sonar.api.web.UserRole;
import org.sonar.server.notification.EmailNotificationHandler;
@@ -34,7 +35,6 @@ import org.sonar.server.notification.email.EmailNotificationChannel.EmailDeliver
import static java.util.Collections.emptySet;
import static org.sonar.core.util.stream.MoreCollectors.index;
-import static org.sonar.core.util.stream.MoreCollectors.toSet;
public class ReportAnalysisFailureNotificationHandler extends EmailNotificationHandler<ReportAnalysisFailureNotification> {
private static final String KEY = "CeReportTaskFailure";
@@ -76,7 +76,7 @@ public class ReportAnalysisFailureNotificationHandler extends EmailNotificationH
return notificationsByProjectKey.asMap().entrySet()
.stream()
.flatMap(e -> toEmailDeliveryRequests(e.getKey(), e.getValue()))
- .collect(toSet(notifications.size()));
+ .collect(Collectors.toSet());
}
private Stream<? extends EmailDeliveryRequest> toEmailDeliveryRequests(String projectKey, Collection<ReportAnalysisFailureNotification> notifications) {
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java
index 9a6b970265d..21b4d1dfbf5 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java
@@ -41,7 +41,6 @@ import org.sonar.ce.task.projectanalysis.component.PathAwareVisitorAdapter;
import org.sonar.ce.task.projectanalysis.component.ProjectPersister;
import org.sonar.ce.task.projectanalysis.component.TreeRootHolder;
import org.sonar.ce.task.step.ComputationStep;
-import org.sonar.core.util.stream.MoreCollectors;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.component.ComponentDto;
@@ -111,7 +110,7 @@ public class PersistComponentsStep implements ComputationStep {
Set<String> uuids = dtos.stream()
.filter(ComponentDto::isEnabled)
.map(ComponentDto::uuid)
- .collect(MoreCollectors.toSet(dtos.size()));
+ .collect(Collectors.toSet());
dbClient.componentDao().updateBEnabledToFalse(dbSession, uuids);
disabledComponentsHolder.setUuids(uuids);
}
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/SendIssueNotificationsStep.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/SendIssueNotificationsStep.java
index 15a82c84e53..2d11188ec35 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/SendIssueNotificationsStep.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/SendIssueNotificationsStep.java
@@ -57,7 +57,6 @@ import org.sonar.server.notification.NotificationService;
import static java.util.Collections.singleton;
import static java.util.stream.Collectors.toMap;
import static java.util.stream.StreamSupport.stream;
-import static org.sonar.core.util.stream.MoreCollectors.toSet;
import static org.sonar.db.component.BranchType.PULL_REQUEST;
/**
@@ -207,7 +206,7 @@ public class SendIssueNotificationsStep implements ComputationStep {
return myNewIssuesNotification;
})
- .collect(toSet(statistics.getAssigneesStatistics().size()));
+ .collect(Collectors.toSet());
notificationStatistics.myNewIssuesDeliveries += service.deliverEmails(myNewIssuesNotifications);
notificationStatistics.myNewIssues += myNewIssuesNotifications.size();
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/CeDistributedInformationImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/CeDistributedInformationImpl.java
index a3c3a3b8334..c6d23f4e94a 100644
--- a/server/sonar-ce/src/main/java/org/sonar/ce/CeDistributedInformationImpl.java
+++ b/server/sonar-ce/src/main/java/org/sonar/ce/CeDistributedInformationImpl.java
@@ -33,7 +33,6 @@ import org.sonar.ce.taskprocessor.CeWorkerFactory;
import org.sonar.process.cluster.hz.HazelcastMember;
import org.sonar.process.cluster.hz.HazelcastObjects;
-import static org.sonar.core.util.stream.MoreCollectors.toSet;
import static org.sonar.process.cluster.hz.HazelcastObjects.WORKER_UUIDS;
/**
@@ -64,7 +63,7 @@ public class CeDistributedInformationImpl implements CeDistributedInformation, S
@Override
public void broadcastWorkerUUIDs() {
Set<CeWorker> workers = ceCeWorkerFactory.getWorkers();
- Set<String> workerUuids = workers.stream().map(CeWorker::getUUID).collect(toSet(workers.size()));
+ Set<String> workerUuids = workers.stream().map(CeWorker::getUUID).collect(Collectors.toSet());
getClusteredWorkerUUIDs().put(hazelcastMember.getUuid(), workerUuids);
}
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/StandaloneCeDistributedInformation.java b/server/sonar-ce/src/main/java/org/sonar/ce/StandaloneCeDistributedInformation.java
index 657403b3ebe..c9e5a7e2eb1 100644
--- a/server/sonar-ce/src/main/java/org/sonar/ce/StandaloneCeDistributedInformation.java
+++ b/server/sonar-ce/src/main/java/org/sonar/ce/StandaloneCeDistributedInformation.java
@@ -23,11 +23,11 @@ import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
+import java.util.stream.Collectors;
import org.sonar.ce.taskprocessor.CeWorker;
import org.sonar.ce.taskprocessor.CeWorkerFactory;
import static com.google.common.base.Preconditions.checkState;
-import static org.sonar.core.util.stream.MoreCollectors.toSet;
/**
* Provide the set of worker's UUID in a non clustered SonarQube instance
@@ -51,7 +51,7 @@ public class StandaloneCeDistributedInformation implements CeDistributedInformat
@Override
public void broadcastWorkerUUIDs() {
Set<CeWorker> workers = ceCeWorkerFactory.getWorkers();
- workerUUIDs = workers.stream().map(CeWorker::getUUID).collect(toSet(workers.size()));
+ workerUUIDs = workers.stream().map(CeWorker::getUUID).collect(Collectors.toSet());
}
/**
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeWorkerFactoryImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeWorkerFactoryImpl.java
index 440687c46f3..5e55dd0be38 100644
--- a/server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeWorkerFactoryImpl.java
+++ b/server/sonar-ce/src/main/java/org/sonar/ce/taskprocessor/CeWorkerFactoryImpl.java
@@ -21,10 +21,10 @@ package org.sonar.ce.taskprocessor;
import java.util.Collections;
import java.util.Set;
+import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.sonar.ce.queue.InternalCeQueue;
import org.sonar.core.util.UuidFactory;
-import org.sonar.core.util.stream.MoreCollectors;
import org.springframework.beans.factory.annotation.Autowired;
public class CeWorkerFactoryImpl implements CeWorkerFactory {
@@ -57,7 +57,7 @@ public class CeWorkerFactoryImpl implements CeWorkerFactory {
public CeWorker create(int ordinal) {
String uuid = uuidFactory.create();
CeWorkerImpl ceWorker = new CeWorkerImpl(ordinal, uuid, queue, taskProcessorRepository, ceWorkerController, executionListeners);
- ceWorkers = Stream.concat(ceWorkers.stream(), Stream.of(ceWorker)).collect(MoreCollectors.toSet(ceWorkers.size() + 1));
+ ceWorkers = Stream.concat(ceWorkers.stream(), Stream.of(ceWorker)).collect(Collectors.toSet());
return ceWorker;
}
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/es/Indexers.java b/server/sonar-server-common/src/main/java/org/sonar/server/es/Indexers.java
index 78bf19cf2d3..00e23edbe4b 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/es/Indexers.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/es/Indexers.java
@@ -21,7 +21,6 @@ package org.sonar.server.es;
import java.util.Collection;
import java.util.stream.Collectors;
-import org.sonar.core.util.stream.MoreCollectors;
import org.sonar.db.DbSession;
import org.sonar.db.component.BranchDto;
import org.sonar.db.entity.EntityDto;
@@ -63,7 +62,7 @@ public interface Indexers {
default void commitAndIndexEntities(DbSession dbSession, Collection<? extends EntityDto> entities, EntityEvent cause) {
Collection<String> entityUuids = entities.stream()
.map(EntityDto::getUuid)
- .collect(MoreCollectors.toSet(entities.size()));
+ .collect(Collectors.toSet());
commitAndIndexOnEntityEvent(dbSession, entityUuids, cause);
}
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/es/searchrequest/RequestFiltersComputer.java b/server/sonar-server-common/src/main/java/org/sonar/server/es/searchrequest/RequestFiltersComputer.java
index ca67ccc83e8..a590160163c 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/es/searchrequest/RequestFiltersComputer.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/es/searchrequest/RequestFiltersComputer.java
@@ -27,12 +27,12 @@ import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.function.BiPredicate;
+import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
-import org.sonar.core.util.stream.MoreCollectors;
import org.sonar.server.es.searchrequest.TopAggregationDefinition.FilterScope;
import static com.google.common.base.Preconditions.checkArgument;
@@ -81,7 +81,7 @@ public class RequestFiltersComputer {
Set<FilterScope> enabledStickyTopAggregationtedFieldNames = topAggregations.stream()
.filter(TopAggregationDefinition::isSticky)
.map(TopAggregationDefinition::getFilterScope)
- .collect(MoreCollectors.toSet(topAggregations.size()));
+ .collect(Collectors.toSet());
// use LinkedHashMap over MoreCollectors.uniqueIndex to preserve order and write UTs more easily
Map<FilterNameAndScope, QueryBuilder> res = new LinkedHashMap<>();
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/ChangesOnMyIssueNotificationHandler.java b/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/ChangesOnMyIssueNotificationHandler.java
index 4be0cd5a127..f8e45f5ea77 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/ChangesOnMyIssueNotificationHandler.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/ChangesOnMyIssueNotificationHandler.java
@@ -38,7 +38,6 @@ import org.sonar.server.notification.NotificationManager.EmailRecipient;
import org.sonar.server.notification.email.EmailNotificationChannel;
import org.sonar.server.notification.email.EmailNotificationChannel.EmailDeliveryRequest;
-import static org.sonar.core.util.stream.MoreCollectors.toSet;
import static org.sonar.core.util.stream.MoreCollectors.unorderedFlattenIndex;
import static org.sonar.core.util.stream.MoreCollectors.unorderedIndex;
import static org.sonar.server.notification.NotificationManager.SubscriberPermissionsOnProject.ALL_MUST_HAVE_ROLE_USER;
@@ -111,7 +110,7 @@ public class ChangesOnMyIssueNotificationHandler extends EmailNotificationHandle
.filter(notification -> !notification.getChange().isAuthorLogin(recipient.login()))
.map(notification -> toEmailDeliveryRequest(notification, recipient, projectKeys)))
.filter(Objects::nonNull)
- .collect(toSet(notificationsWithPeerChangedIssues.size()));
+ .collect(Collectors.toSet());
}
SetMultimap<String, String> assigneeLoginsOfPeerChangedIssuesByProjectKey = notificationsWithPeerChangedIssues.stream()
@@ -144,7 +143,7 @@ public class ChangesOnMyIssueNotificationHandler extends EmailNotificationHandle
.map(notification -> toEmailDeliveryRequest(notification, recipient, subscribedProjectKeys))
.filter(Objects::nonNull);
})
- .collect(toSet(notificationsWithPeerChangedIssues.size()));
+ .collect(Collectors.toSet());
}
/**
@@ -155,10 +154,11 @@ public class ChangesOnMyIssueNotificationHandler extends EmailNotificationHandle
*/
@CheckForNull
private static EmailDeliveryRequest toEmailDeliveryRequest(NotificationWithProjectKeys notification, EmailRecipient recipient, Set<String> subscribedProjectKeys) {
+ notification.getIssues();
Set<ChangedIssue> recipientIssuesByProject = notification.getIssues().stream()
.filter(issue -> issue.getAssignee().filter(assignee -> recipient.login().equals(assignee.getLogin())).isPresent())
.filter(issue -> subscribedProjectKeys.contains(issue.getProject().getKey()))
- .collect(toSet(notification.getIssues().size()));
+ .collect(Collectors.toSet());
if (recipientIssuesByProject.isEmpty()) {
return null;
}
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/FPOrWontFixNotificationHandler.java b/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/FPOrWontFixNotificationHandler.java
index d0f463123e7..554aa49ed83 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/FPOrWontFixNotificationHandler.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/FPOrWontFixNotificationHandler.java
@@ -42,7 +42,6 @@ import static com.google.common.collect.Sets.intersection;
import static java.util.Collections.emptySet;
import static java.util.Optional.of;
import static java.util.Optional.ofNullable;
-import static org.sonar.core.util.stream.MoreCollectors.toSet;
import static org.sonar.core.util.stream.MoreCollectors.unorderedFlattenIndex;
import static org.sonar.core.util.stream.MoreCollectors.unorderedIndex;
import static org.sonar.server.issue.notification.FPOrWontFixNotification.FpOrWontFix.FP;
@@ -105,7 +104,7 @@ public class FPOrWontFixNotificationHandler extends EmailNotificationHandler<Iss
Set<EmailRecipient> recipients = notificationManager.findSubscribedEmailRecipients(KEY, projectKeys.iterator().next(), ALL_MUST_HAVE_ROLE_USER);
return changeNotificationsWithFpOrWontFix.stream()
.flatMap(notification -> toRequests(notification, projectKeys, recipients))
- .collect(toSet(changeNotificationsWithFpOrWontFix.size()));
+ .collect(Collectors.toSet());
}
Set<EmailRecipientAndProject> recipientsByProjectKey = projectKeys.stream()
@@ -130,7 +129,7 @@ public class FPOrWontFixNotificationHandler extends EmailNotificationHandler<Iss
return recipientsByProjectKeys.asMap().entrySet().stream()
.flatMap(entry -> toRequests(notification, entry.getKey(), entry.getValue()));
})
- .collect(toSet(changeNotificationsWithFpOrWontFix.size()));
+ .collect(Collectors.toSet());
}
private static Stream<EmailDeliveryRequest> toRequests(NotificationWithProjectKeys notification, Set<String> projectKeys, Collection<EmailRecipient> recipients) {
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/IssuesChangesNotificationSerializer.java b/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/IssuesChangesNotificationSerializer.java
index d7c9b93e069..872e589de6c 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/IssuesChangesNotificationSerializer.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/IssuesChangesNotificationSerializer.java
@@ -36,7 +36,6 @@ import org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.User
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import static java.util.Optional.ofNullable;
-import static org.sonar.core.util.stream.MoreCollectors.toSet;
import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex;
public class IssuesChangesNotificationSerializer {
@@ -93,7 +92,7 @@ public class IssuesChangesNotificationSerializer {
.setRule(rules.get(issue.ruleKey))
.setProject(projects.get(issue.projectUuid))
.build())
- .collect(toSet(issues.size()));
+ .collect(Collectors.toSet());
}
private static void serializeIssues(IssuesChangesNotification res, Set<ChangedIssue> issues) {
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/MyNewIssuesNotificationHandler.java b/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/MyNewIssuesNotificationHandler.java
index 14d3d6b0e4e..c0fc5147598 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/MyNewIssuesNotificationHandler.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/MyNewIssuesNotificationHandler.java
@@ -81,7 +81,7 @@ public class MyNewIssuesNotificationHandler extends EmailNotificationHandler<MyN
return notificationsByProjectKey.asMap().entrySet()
.stream()
.flatMap(e -> toEmailDeliveryRequests(e.getKey(), e.getValue()))
- .collect(MoreCollectors.toSet(notifications.size()));
+ .collect(Collectors.toSet());
}
private Stream<? extends EmailDeliveryRequest> toEmailDeliveryRequests(String projectKey, Collection<MyNewIssuesNotification> notifications) {
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/NewIssuesNotificationHandler.java b/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/NewIssuesNotificationHandler.java
index d1de9b0465f..9a494754841 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/NewIssuesNotificationHandler.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/NewIssuesNotificationHandler.java
@@ -23,6 +23,7 @@ import com.google.common.collect.Multimap;
import java.util.Collection;
import java.util.Optional;
import java.util.Set;
+import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.sonar.server.notification.EmailNotificationHandler;
import org.sonar.server.notification.NotificationDispatcherMetadata;
@@ -32,7 +33,6 @@ import org.sonar.server.notification.email.EmailNotificationChannel.EmailDeliver
import static java.util.Collections.emptySet;
import static org.sonar.core.util.stream.MoreCollectors.index;
-import static org.sonar.core.util.stream.MoreCollectors.toSet;
import static org.sonar.server.notification.NotificationManager.SubscriberPermissionsOnProject.ALL_MUST_HAVE_ROLE_USER;
public class NewIssuesNotificationHandler extends EmailNotificationHandler<NewIssuesNotification> {
@@ -75,7 +75,7 @@ public class NewIssuesNotificationHandler extends EmailNotificationHandler<NewIs
return notificationsByProjectKey.asMap().entrySet()
.stream()
.flatMap(e -> toEmailDeliveryRequests(e.getKey(), e.getValue()))
- .collect(toSet(notifications.size()));
+ .collect(Collectors.toSet());
}
private Stream<? extends EmailDeliveryRequest> toEmailDeliveryRequests(String projectKey, Collection<NewIssuesNotification> notifications) {
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/notification/NotificationService.java b/server/sonar-server-common/src/main/java/org/sonar/server/notification/NotificationService.java
index c85cf7f0bb8..e24180532f6 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/notification/NotificationService.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/notification/NotificationService.java
@@ -29,6 +29,7 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
+import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.sonar.api.ce.ComputeEngineSide;
@@ -37,7 +38,6 @@ import org.sonar.api.notifications.NotificationChannel;
import org.sonar.api.server.ServerSide;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.core.util.stream.MoreCollectors;
import org.sonar.db.DbClient;
import org.springframework.beans.factory.annotation.Autowired;
@@ -166,7 +166,7 @@ public class NotificationService {
.filter(Optional::isPresent)
.map(Optional::get)
.map(NotificationDispatcherMetadata::getDispatcherKey)
- .collect(MoreCollectors.toSet(notificationTypes.size()));
+ .collect(Collectors.toSet());
return dbClient.propertiesDao().hasProjectNotificationSubscribersForDispatchers(projectUuid, dispatcherKeys);
}
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/qualitygate/QualityGate.java b/server/sonar-server-common/src/main/java/org/sonar/server/qualitygate/QualityGate.java
index 5d066b4de28..c03a0d8f6e6 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/qualitygate/QualityGate.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/qualitygate/QualityGate.java
@@ -21,10 +21,10 @@ package org.sonar.server.qualitygate;
import java.util.Objects;
import java.util.Set;
+import java.util.stream.Collectors;
import javax.annotation.concurrent.Immutable;
import static java.util.Objects.requireNonNull;
-import static org.sonar.core.util.stream.MoreCollectors.toSet;
@Immutable
public class QualityGate {
@@ -38,7 +38,7 @@ public class QualityGate {
this.conditions = requireNonNull(conditions, "conditions can't be null")
.stream()
.map(c -> requireNonNull(c, "condition can't be null"))
- .collect(toSet(conditions.size()));
+ .collect(Collectors.toSet());
}
public String getId() {
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/qualitygate/notification/QGChangeNotificationHandler.java b/server/sonar-server-common/src/main/java/org/sonar/server/qualitygate/notification/QGChangeNotificationHandler.java
index a47bb5b95ff..99cbcd71c5d 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/qualitygate/notification/QGChangeNotificationHandler.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/qualitygate/notification/QGChangeNotificationHandler.java
@@ -23,6 +23,7 @@ import com.google.common.collect.Multimap;
import java.util.Collection;
import java.util.Optional;
import java.util.Set;
+import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.sonar.server.notification.EmailNotificationHandler;
import org.sonar.server.notification.NotificationDispatcherMetadata;
@@ -32,7 +33,6 @@ import org.sonar.server.notification.email.EmailNotificationChannel.EmailDeliver
import static java.util.Collections.emptySet;
import static org.sonar.core.util.stream.MoreCollectors.index;
-import static org.sonar.core.util.stream.MoreCollectors.toSet;
import static org.sonar.server.notification.NotificationManager.SubscriberPermissionsOnProject.ALL_MUST_HAVE_ROLE_USER;
public class QGChangeNotificationHandler extends EmailNotificationHandler<QGChangeNotification> {
@@ -75,7 +75,7 @@ public class QGChangeNotificationHandler extends EmailNotificationHandler<QGChan
return notificationsByProjectKey.asMap().entrySet()
.stream()
.flatMap(e -> toEmailDeliveryRequests(e.getKey(), e.getValue()))
- .collect(toSet(notifications.size()));
+ .collect(Collectors.toSet());
}
private Stream<? extends EmailDeliveryRequest> toEmailDeliveryRequests(String projectKey, Collection<QGChangeNotification> notifications) {
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexer.java b/server/sonar-server-common/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexer.java
index 1770ec7c2e8..26fbe679031 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexer.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexer.java
@@ -25,6 +25,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.search.SearchRequest;
@@ -52,7 +53,6 @@ import org.sonar.server.qualityprofile.ActiveRuleInheritance;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import static org.sonar.core.util.stream.MoreCollectors.toArrayList;
-import static org.sonar.core.util.stream.MoreCollectors.toSet;
import static org.sonar.server.qualityprofile.index.ActiveRuleDoc.docIdOf;
import static org.sonar.server.rule.index.RuleIndexDefinition.FIELD_ACTIVE_RULE_PROFILE_UUID;
import static org.sonar.server.rule.index.RuleIndexDefinition.TYPE_ACTIVE_RULE;
@@ -179,7 +179,7 @@ public class ActiveRuleIndexer implements ResilientIndexer {
Set<String> docIds = activeRuleItems.keySet();
return docIds.stream()
.map(ActiveRuleDoc::activeRuleUuidOf)
- .collect(toSet(docIds.size()));
+ .collect(Collectors.toSet());
}
private IndexingResult doIndexRuleProfiles(DbSession dbSession, Map<String, EsQueueDto> ruleProfileItems) {
diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/ServerUserSession.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/ServerUserSession.java
index 33d1ddb72e2..96af8cc804e 100644
--- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/ServerUserSession.java
+++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/ServerUserSession.java
@@ -34,7 +34,6 @@ import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.Scopes;
-import org.sonar.core.util.stream.MoreCollectors;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.component.BranchDto;
@@ -340,7 +339,7 @@ public class ServerUserSession extends AbstractUserSession {
}
return permissionKeys.stream()
.map(GlobalPermission::fromKey)
- .collect(MoreCollectors.toSet(permissionKeys.size()));
+ .collect(toSet());
}
private Set<String> loadDbPermissions(DbSession dbSession, String entityUuid) {
@@ -383,7 +382,7 @@ public class ServerUserSession extends AbstractUserSession {
Set<String> copyComponentsUuid = components.stream()
.map(ComponentDto::getCopyComponentUuid)
.filter(Objects::nonNull)
- .collect(MoreCollectors.toSet(components.size()));
+ .collect(toSet());
return dbClient.componentDao().selectByUuids(dbSession, copyComponentsUuid).stream()
.collect(Collectors.toMap(ComponentDto::uuid, componentDto -> componentDto));
}
diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/SingleDeprecatedRuleKey.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/SingleDeprecatedRuleKey.java
index 4da7922c3c1..ff72d360f2b 100644
--- a/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/SingleDeprecatedRuleKey.java
+++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/SingleDeprecatedRuleKey.java
@@ -21,12 +21,12 @@ package org.sonar.server.rule;
import java.util.Objects;
import java.util.Set;
+import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
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;
@Immutable
@@ -46,13 +46,14 @@ class SingleDeprecatedRuleKey {
}
public static Set<SingleDeprecatedRuleKey> from(RulesDefinition.Rule rule) {
+ rule.deprecatedRuleKeys();
return rule.deprecatedRuleKeys().stream()
.map(r -> new SingleDeprecatedRuleKey()
.setNewRepositoryKey(rule.repository().key())
.setNewRuleKey(rule.key())
.setOldRepositoryKey(r.repository())
.setOldRuleKey(r.rule()))
- .collect(MoreCollectors.toSet(rule.deprecatedRuleKeys().size()));
+ .collect(Collectors.toSet());
}
public static SingleDeprecatedRuleKey from(DeprecatedRuleKeyDto rule) {
diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java
index 8832c898f19..685f9597d1a 100644
--- a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java
+++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java
@@ -72,7 +72,6 @@ import org.sonar.api.server.rule.RulesDefinition.OwaspTop10Version;
import org.sonar.api.server.rule.RulesDefinition.PciDssVersion;
import org.sonar.api.utils.DateUtils;
import org.sonar.api.utils.System2;
-import org.sonar.core.util.stream.MoreCollectors;
import org.sonar.server.es.EsClient;
import org.sonar.server.es.EsUtils;
import org.sonar.server.es.SearchOptions;
@@ -653,7 +652,7 @@ public class IssueIndex {
.map(FACETS_BY_NAME::get)
.filter(Objects::nonNull)
.map(Facet::getTopAggregationDef))
- .collect(MoreCollectors.toSet(facetNames.size()));
+ .collect(Collectors.toSet());
return new RequestFiltersComputer(allFilters, facets);
}
diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java
index 7e34b0123a0..0824989ff91 100644
--- a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java
+++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java
@@ -48,7 +48,6 @@ import org.sonar.api.resources.Qualifiers;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rules.RuleType;
import org.sonar.api.server.ServerSide;
-import org.sonar.core.util.stream.MoreCollectors;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.component.BranchDto;
@@ -98,7 +97,7 @@ public class IssueQueryFactory {
public static final Set<String> ISSUE_TYPE_NAMES = Arrays.stream(RuleType.values())
.filter(t -> t != RuleType.SECURITY_HOTSPOT)
.map(Enum::name)
- .collect(MoreCollectors.toSet(RuleType.values().length - 1));
+ .collect(Collectors.toSet());
private static final ComponentDto UNKNOWN_COMPONENT = new ComponentDto().setUuid(UNKNOWN).setBranchUuid(UNKNOWN);
private static final Set<String> QUALIFIERS_WITHOUT_LEAK_PERIOD = new HashSet<>(Arrays.asList(Qualifiers.APP, Qualifiers.VIEW, Qualifiers.SUBVIEW));
private final DbClient dbClient;
diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java
index 7873966b489..6eac0d57402 100644
--- a/server/sonar-webserver-es/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java
+++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java
@@ -105,7 +105,6 @@ import static org.sonar.api.measures.CoreMetrics.SECURITY_HOTSPOTS_REVIEWED_KEY;
import static org.sonar.api.measures.CoreMetrics.SECURITY_RATING_KEY;
import static org.sonar.api.measures.CoreMetrics.SECURITY_REVIEW_RATING_KEY;
import static org.sonar.api.measures.CoreMetrics.SQALE_RATING_KEY;
-import static org.sonar.core.util.stream.MoreCollectors.toSet;
import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex;
import static org.sonar.server.es.EsUtils.escapeSpecialRegexChars;
import static org.sonar.server.es.EsUtils.termsToMap;
@@ -242,7 +241,7 @@ public class ProjectMeasuresIndex {
.map(FACETS_BY_NAME::get)
.filter(Objects::nonNull)
.map(Facet::getTopAggregationDef)
- .collect(toSet(facetNames.size()));
+ .collect(Collectors.toSet());
return new RequestFiltersComputer(allFilters, facets);
}
diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/project/ws/UpdateVisibilityActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/project/ws/UpdateVisibilityActionIT.java
index f29fb79e9da..295b305a2ea 100644
--- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/project/ws/UpdateVisibilityActionIT.java
+++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/project/ws/UpdateVisibilityActionIT.java
@@ -22,6 +22,7 @@ package org.sonar.server.project.ws;
import java.util.Arrays;
import java.util.Random;
import java.util.Set;
+import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import org.junit.Rule;
@@ -34,7 +35,6 @@ import org.sonar.api.utils.System2;
import org.sonar.api.web.UserRole;
import org.sonar.core.util.SequenceUuidFactory;
import org.sonar.core.util.Uuids;
-import org.sonar.core.util.stream.MoreCollectors;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.DbTester;
@@ -84,7 +84,7 @@ public class UpdateVisibilityActionIT {
private static final String PRIVATE = "private";
private static final Set<String> GLOBAL_PERMISSIONS_NAME_SET = stream(GlobalPermission.values()).map(GlobalPermission::getKey)
- .collect(MoreCollectors.toSet(GlobalPermission.values().length));
+ .collect(Collectors.toSet());
@Rule
public final DbTester dbTester = DbTester.create(System2.INSTANCE);
@@ -96,8 +96,8 @@ public class UpdateVisibilityActionIT {
private final ResourceTypes resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT);
private final PermissionService permissionService = new PermissionServiceImpl(resourceTypes);
private final Set<String> PROJECT_PERMISSIONS_BUT_USER_AND_CODEVIEWER = permissionService.getAllProjectPermissions().stream()
- .filter(perm -> !perm.equals(UserRole.USER) && !perm.equals(UserRole.CODEVIEWER))
- .collect(MoreCollectors.toSet(permissionService.getAllProjectPermissions().size() - 2));
+ .filter(perm -> !perm.equals(UserRole.USER) && !perm.equals(UserRole.CODEVIEWER))
+ .collect(Collectors.toSet());
private final DbClient dbClient = dbTester.getDbClient();
private final DbSession dbSession = dbTester.getSession();
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/TaskFormatter.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/TaskFormatter.java
index ed00c1fde3c..e6dd055a0c3 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/TaskFormatter.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/TaskFormatter.java
@@ -48,7 +48,6 @@ import static java.lang.String.format;
import static java.util.Collections.singletonList;
import static java.util.Optional.ofNullable;
import static org.sonar.api.utils.DateUtils.formatDateTime;
-import static org.sonar.core.util.stream.MoreCollectors.toSet;
import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex;
/**
@@ -194,7 +193,7 @@ public class TaskFormatter {
.filter(Objects::nonNull)
.map(CeQueueDto::getComponentUuid)
.filter(Objects::nonNull)
- .collect(toSet(ceQueueDtos.size()));
+ .collect(Collectors.toSet());
}
static DtoCache forActivityDtos(DbClient dbClient, DbSession dbSession, Collection<CeActivityDto> ceActivityDtos) {
@@ -216,7 +215,7 @@ public class TaskFormatter {
.filter(Objects::nonNull)
.map(CeActivityDto::getComponentUuid)
.filter(Objects::nonNull)
- .collect(toSet(ceActivityDtos.size()));
+ .collect(Collectors.toSet());
}
@CheckForNull
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ComponentFinder.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ComponentFinder.java
index 44190a17471..0a74c3e781e 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ComponentFinder.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ComponentFinder.java
@@ -22,12 +22,12 @@ package org.sonar.server.component;
import java.util.Collection;
import java.util.Optional;
import java.util.Set;
+import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.ResourceType;
import org.sonar.api.resources.ResourceTypes;
import org.sonar.api.resources.Scopes;
-import org.sonar.core.util.stream.MoreCollectors;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.component.BranchDto;
@@ -229,7 +229,7 @@ public class ComponentFinder {
return rootTypes
.stream()
.map(ResourceType::getQualifier)
- .collect(MoreCollectors.toSet(rootTypes.size()));
+ .collect(Collectors.toSet());
}
public ComponentDto getByKeyAndBranch(DbSession dbSession, String key, String branch) {
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SearchProjectsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SearchProjectsAction.java
index 3ea63859a0a..d03fa774fc4 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SearchProjectsAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SearchProjectsAction.java
@@ -48,7 +48,6 @@ import org.sonar.api.server.ws.WebService;
import org.sonar.api.server.ws.WebService.Param;
import org.sonar.core.platform.EditionProvider.Edition;
import org.sonar.core.platform.PlatformEditionProvider;
-import org.sonar.core.util.stream.MoreCollectors;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.component.BranchDto;
@@ -325,7 +324,7 @@ public class SearchProjectsAction implements ComponentsWsAction {
Set<String> favoriteDbUuids = props.stream()
.map(PropertyDto::getEntityUuid)
.filter(Objects::nonNull)
- .collect(MoreCollectors.toSet(props.size()));
+ .collect(Collectors.toSet());
return dbClient.projectDao().selectByUuids(dbSession, favoriteDbUuids).stream()
.map(ProjectDto::getUuid)
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SuggestionsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SuggestionsAction.java
index eb56570fd3e..a34f3ddcf5f 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SuggestionsAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SuggestionsAction.java
@@ -177,7 +177,7 @@ public class SuggestionsAction implements ComponentsWsAction {
return newBuilder().build();
}
- Set<String> favoriteUuids = favorites.stream().map(EntityDto::getUuid).collect(MoreCollectors.toSet(favorites.size()));
+ Set<String> favoriteUuids = favorites.stream().map(EntityDto::getUuid).collect(Collectors.toSet());
Comparator<EntityDto> favoriteComparator = Comparator.comparing(c -> favoriteUuids.contains(c.getUuid()) ? -1 : +1);
Comparator<EntityDto> comparator = favoriteComparator.thenComparing(EntityDto::getName);
@@ -207,7 +207,7 @@ public class SuggestionsAction implements ComponentsWsAction {
}
List<EntityDto> favorites = favoriteFinder.list();
- Set<String> favoriteKeys = favorites.stream().map(EntityDto::getKey).collect(MoreCollectors.toSet(favorites.size()));
+ Set<String> favoriteKeys = favorites.stream().map(EntityDto::getKey).collect(Collectors.toSet());
SuggestionQuery.Builder queryBuilder = SuggestionQuery.builder()
.setQuery(query)
.setRecentlyBrowsedKeys(recentlyBrowsedKeys)
@@ -226,7 +226,7 @@ public class SuggestionsAction implements ComponentsWsAction {
.map(ComponentHit::getUuid)
.collect(Collectors.toSet());
List<EntityDto> entities = dbClient.entityDao().selectByUuids(dbSession, entityUuids);
- Set<String> favoriteUuids = favorites.stream().map(EntityDto::getUuid).collect(MoreCollectors.toSet(favorites.size()));
+ Set<String> favoriteUuids = favorites.stream().map(EntityDto::getUuid).collect(Collectors.toSet());
SuggestionsWsResponse.Builder searchWsResponse = buildResponse(recentlyBrowsedKeys, favoriteUuids, componentsPerQualifiers, entities, skip + limit);
getWarning(query).ifPresent(searchWsResponse::setWarning);
return searchWsResponse.build();
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/WebIssueStorage.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/WebIssueStorage.java
index 10c4de32b87..543b185b7c3 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/WebIssueStorage.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/WebIssueStorage.java
@@ -45,7 +45,6 @@ import org.sonar.server.rule.ServerRuleFinder;
import static com.google.common.base.MoreObjects.firstNonNull;
import static com.google.common.collect.Lists.newArrayList;
import static java.util.Collections.emptyList;
-import static org.sonar.core.util.stream.MoreCollectors.toSet;
/**
* Save issues into database. It is executed :
@@ -88,10 +87,10 @@ public class WebIssueStorage extends IssueStorage {
Collection<IssueDto> updated = update(issuesToUpdate, now);
doAfterSave(dbSession, Stream.concat(inserted.stream(), updated.stream())
- .collect(toSet(issuesToInsert.size() + issuesToUpdate.size())));
+ .collect(Collectors.toSet()));
return Stream.concat(inserted.stream(), updated.stream())
- .collect(toSet(issuesToInsert.size() + issuesToUpdate.size()));
+ .collect(Collectors.toSet());
}
private void doAfterSave(DbSession dbSession, Collection<IssueDto> issues) {
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/BulkChangeAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/BulkChangeAction.java
index 0aa9dd6be99..d9f574a148f 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/BulkChangeAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/BulkChangeAction.java
@@ -90,7 +90,6 @@ import static org.sonar.api.rules.RuleType.SECURITY_HOTSPOT;
import static org.sonar.core.issue.IssueChangeContext.issueChangeContextByUserBuilder;
import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01;
import static org.sonar.core.util.Uuids.UUID_EXAMPLE_02;
-import static org.sonar.core.util.stream.MoreCollectors.toSet;
import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex;
import static org.sonar.server.es.SearchOptions.MAX_PAGE_SIZE;
import static org.sonar.server.issue.AbstractChangeTagsAction.TAGS_PARAMETER;
@@ -279,7 +278,7 @@ public class BulkChangeAction implements IssuesWsAction {
.filter(issue -> issue.updateDate() != null)
.map(issue -> toNotification(bulkChangeData, userDtoByUuid, issue))
.filter(Objects::nonNull)
- .collect(toSet(issues.size()));
+ .collect(Collectors.toSet());
if (changedIssues.isEmpty()) {
return;
@@ -304,7 +303,7 @@ public class BulkChangeAction implements IssuesWsAction {
// should not happen but filter it out anyway to avoid NPE in oldestUpdateDate call below
.filter(issue -> issue.updateDate() != null)
.filter(Objects::nonNull)
- .collect(toSet(issues.size()));
+ .collect(Collectors.toSet());
if (changedIssues.isEmpty()) {
return;
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java
index 288929d9879..d48d537f88c 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java
@@ -111,7 +111,7 @@ public class SearchResponseLoader {
private List<IssueDto> loadIssues(SearchResponseData preloadedResponseData, Collector collector, DbSession dbSession) {
List<IssueDto> preloadedIssues = preloadedResponseData.getIssues();
- Set<String> preloadedIssueKeys = preloadedIssues.stream().map(IssueDto::getKey).collect(MoreCollectors.toSet(preloadedIssues.size()));
+ Set<String> preloadedIssueKeys = preloadedIssues.stream().map(IssueDto::getKey).collect(Collectors.toSet());
ImmutableSet<String> issueKeys = ImmutableSet.copyOf(collector.getIssueKeys());
Set<String> issueKeysToLoad = copyOf(difference(issueKeys, preloadedIssueKeys));
@@ -141,7 +141,7 @@ public class SearchResponseLoader {
private void loadComponents(SearchResponseData preloadedResponseData, Collector collector, DbSession dbSession, SearchResponseData result) {
Collection<ComponentDto> preloadedComponents = preloadedResponseData.getComponents();
- Set<String> preloadedComponentUuids = preloadedComponents.stream().map(ComponentDto::uuid).collect(MoreCollectors.toSet(preloadedComponents.size()));
+ Set<String> preloadedComponentUuids = preloadedComponents.stream().map(ComponentDto::uuid).collect(Collectors.toSet());
Set<String> componentUuidsToLoad = copyOf(difference(collector.getComponentUuids(), preloadedComponentUuids));
result.addComponents(preloadedComponents);
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/ListAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/ListAction.java
index 962ca757d77..b5c20a2eeff 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/ListAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/ListAction.java
@@ -159,7 +159,7 @@ public class ListAction implements NotificationsWsAction {
Set<String> entityUuids = properties.stream()
.map(PropertyDto::getEntityUuid)
.filter(Objects::nonNull)
- .collect(MoreCollectors.toSet(properties.size()));
+ .collect(Collectors.toSet());
Set<String> authorizedProjectUuids = dbClient.authorizationDao().keepAuthorizedEntityUuids(dbSession, entityUuids, userSession.getUuid(), UserRole.USER);
return dbClient.entityDao().selectByUuids(dbSession, entityUuids)
.stream()
diff --git a/sonar-core/src/main/java/org/sonar/core/util/stream/MoreCollectors.java b/sonar-core/src/main/java/org/sonar/core/util/stream/MoreCollectors.java
index 20da1fab62a..96895b3ac26 100644
--- a/sonar-core/src/main/java/org/sonar/core/util/stream/MoreCollectors.java
+++ b/sonar-core/src/main/java/org/sonar/core/util/stream/MoreCollectors.java
@@ -31,7 +31,6 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.BinaryOperator;
import java.util.function.Function;
@@ -60,10 +59,6 @@ public final class MoreCollectors {
return ImmutableSet.toImmutableSet();
}
- public static <T> Collector<T, ?, Set<T>> toSet(int expectedSize) {
- return Collectors.toSet();
- }
-
/**
* A Collector into an {@link EnumSet} of specified enumeration.
*/
diff --git a/sonar-core/src/test/java/org/sonar/core/util/stream/MoreCollectorsTest.java b/sonar-core/src/test/java/org/sonar/core/util/stream/MoreCollectorsTest.java
index 8ecb9999549..32a4c679fe3 100644
--- a/sonar-core/src/test/java/org/sonar/core/util/stream/MoreCollectorsTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/util/stream/MoreCollectorsTest.java
@@ -47,7 +47,6 @@ import static org.sonar.core.util.stream.MoreCollectors.toArrayList;
import static org.sonar.core.util.stream.MoreCollectors.toHashSet;
import static org.sonar.core.util.stream.MoreCollectors.toImmutableList;
import static org.sonar.core.util.stream.MoreCollectors.toImmutableSet;
-import static org.sonar.core.util.stream.MoreCollectors.toSet;
import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex;
import static org.sonar.core.util.stream.MoreCollectors.unorderedFlattenIndex;
import static org.sonar.core.util.stream.MoreCollectors.unorderedIndex;
@@ -101,11 +100,6 @@ public class MoreCollectorsTest {
}
@Test
- public void toSet_with_size_parallel_stream() {
- assertThat(HUGE_SET.parallelStream().collect(toSet(HUGE_SET.size()))).isEqualTo(HUGE_SET);
- }
-
- @Test
public void toEnumSet() {
Set<MyEnum> res = Stream.of(MyEnum.ONE, MyEnum.ONE, MyEnum.TWO).collect(MoreCollectors.toEnumSet(MyEnum.class));
assertThat(res).isInstanceOf(EnumSet.class)