diff options
121 files changed, 332 insertions, 332 deletions
diff --git a/server/sonar-db-core/src/test/java/org/sonar/db/AbstractDbTester.java b/server/sonar-db-core/src/test/java/org/sonar/db/AbstractDbTester.java index 3295140ed3d..c5a7a4c6b31 100644 --- a/server/sonar-db-core/src/test/java/org/sonar/db/AbstractDbTester.java +++ b/server/sonar-db-core/src/test/java/org/sonar/db/AbstractDbTester.java @@ -63,7 +63,7 @@ import org.dbunit.ext.mssql.InsertIdentityOperation; import org.dbunit.operation.DatabaseOperation; import org.junit.rules.ExternalResource; import org.sonar.api.utils.log.Loggers; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.collect.Lists.asList; @@ -478,7 +478,7 @@ public class AbstractDbTester<T extends CoreTestDb> extends ExternalResource { columnNames.stream() .sorted(PkColumn.ORDERING_BY_INDEX) .map(PkColumn::getName) - .collect(Collectors.toList())); + .collect(MoreCollectors.toList())); } } diff --git a/server/sonar-db-core/src/test/java/org/sonar/db/DatabaseUtilsTest.java b/server/sonar-db-core/src/test/java/org/sonar/db/DatabaseUtilsTest.java index d5855c87a2c..c820f7996bc 100644 --- a/server/sonar-db-core/src/test/java/org/sonar/db/DatabaseUtilsTest.java +++ b/server/sonar-db-core/src/test/java/org/sonar/db/DatabaseUtilsTest.java @@ -36,7 +36,7 @@ import org.junit.rules.ExpectedException; import org.sonar.api.utils.log.LogTester; import org.sonar.api.utils.log.LoggerLevel; import org.sonar.api.utils.log.Loggers; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.dialect.Oracle; import static com.google.common.collect.Lists.newArrayList; @@ -261,7 +261,7 @@ public class DatabaseUtilsTest { List<String> outputs = DatabaseUtils.executeLargeInputs(inputs, input -> { // Check that each partition is only done on 1000 elements max assertThat(input.size()).isLessThanOrEqualTo(1000); - return input.stream().map(String::valueOf).collect(Collectors.toList()); + return input.stream().map(String::valueOf).collect(MoreCollectors.toList()); }); assertThat(outputs).isEqualTo(expectedOutputs); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/KeyLongValue.java b/server/sonar-db-dao/src/main/java/org/sonar/db/KeyLongValue.java index 7ade1b65dde..29aac76218e 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/KeyLongValue.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/KeyLongValue.java @@ -22,7 +22,7 @@ package org.sonar.db; import java.util.List; import java.util.Map; -import static org.sonar.core.util.stream.Collectors.uniqueIndex; +import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex; public class KeyLongValue { diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueChangeDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueChangeDao.java index dc294c166ee..9a9fa026968 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueChangeDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueChangeDao.java @@ -23,7 +23,7 @@ import java.util.Collection; import java.util.List; import java.util.Optional; import org.sonar.core.issue.FieldDiffs; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.Dao; import org.sonar.db.DbSession; @@ -36,7 +36,7 @@ public class IssueChangeDao implements Dao { return selectByTypeAndIssueKeys(session, singletonList(issueKey), IssueChangeDto.TYPE_FIELD_CHANGE) .stream() .map(IssueChangeDto::toFieldDiffs) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); } public List<IssueChangeDto> selectChangelogOfNonClosedIssuesByComponent(DbSession session, String componentUuid) { diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationQuery.java b/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationQuery.java index 794c7ca8fcb..cfa220de493 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationQuery.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationQuery.java @@ -25,7 +25,7 @@ import java.util.Set; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -import static org.sonar.core.util.stream.Collectors.toSet; +import static org.sonar.core.util.stream.MoreCollectors.toSet; public class OrganizationQuery { private static final OrganizationQuery NO_QUERY = newOrganizationQueryBuilder().build(); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/permission/UserPermissionDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/permission/UserPermissionDao.java index 0c3710abcbd..357d6f56d86 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/permission/UserPermissionDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/permission/UserPermissionDao.java @@ -23,7 +23,7 @@ import java.util.Collection; import java.util.List; import javax.annotation.Nullable; import org.apache.ibatis.session.RowBounds; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.Dao; import org.sonar.db.DatabaseUtils; import org.sonar.db.DbSession; @@ -62,7 +62,7 @@ public class UserPermissionDao implements Dao { return dtos.stream() .map(UserPermissionDto::getUserId) .distinct() - .collect(Collectors.toList(dtos.size())); + .collect(MoreCollectors.toList(dtos.size())); } /** diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java index a2a2419102f..5ac77a792b7 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java @@ -27,7 +27,7 @@ import java.util.List; import org.sonar.api.utils.System2; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.Dao; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDao; @@ -117,7 +117,7 @@ public class PurgeDao implements Dao { .setStrategy(Strategy.LEAVES) .build()) .stream().map(ComponentDto::uuid) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); purgeCommands.deleteComponentMeasures(analysisUuids, componentWithoutHistoricalDataUuids); } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/period/DefaultPeriodCleaner.java b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/period/DefaultPeriodCleaner.java index 97f35d5958e..10dab8e6f45 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/period/DefaultPeriodCleaner.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/period/DefaultPeriodCleaner.java @@ -27,14 +27,14 @@ import org.sonar.api.config.Settings; import org.sonar.api.utils.DateUtils; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbSession; import org.sonar.db.purge.IdUuidPair; import org.sonar.db.purge.PurgeDao; import org.sonar.db.purge.PurgeProfiler; import org.sonar.db.purge.PurgeableAnalysisDto; -import static org.sonar.core.util.stream.Collectors.toList; +import static org.sonar.core.util.stream.MoreCollectors.toList; public class DefaultPeriodCleaner { @@ -67,11 +67,11 @@ public class DefaultPeriodCleaner { Joiner.on(", ").join( snapshots.stream() .map(snapshot -> snapshot.getAnalysisUuid() + "@" + DateUtils.formatDateTime(snapshot.getDate())) - .collect(Collectors.toArrayList(snapshots.size())))); + .collect(MoreCollectors.toArrayList(snapshots.size())))); } purgeDao.deleteAnalyses( session, profiler, - snapshots.stream().map(DefaultPeriodCleaner::toIdUuidPair).collect(Collectors.toList(snapshots.size()))); + snapshots.stream().map(DefaultPeriodCleaner::toIdUuidPair).collect(MoreCollectors.toList(snapshots.size()))); return snapshots; } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java index 44853151c4c..050043eab6a 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java @@ -30,7 +30,7 @@ import org.junit.Rule; import org.junit.Test; import org.sonar.api.utils.internal.TestSystem2; import org.sonar.core.util.CloseableIterator; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.Pagination; @@ -381,7 +381,7 @@ public class CeActivityDaoTest { private List<String> selectPageOfUuids(Pagination pagination) { return underTest.selectByQuery(db.getSession(), new CeTaskQuery(), pagination).stream() .map(CeActivityToUuid.INSTANCE::apply) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); } private enum CeActivityToUuid implements Function<CeActivityDto, String> { diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/notification/NotificationDbTester.java b/server/sonar-db-dao/src/test/java/org/sonar/db/notification/NotificationDbTester.java index 2df3453d9b8..43fbcbb14fd 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/notification/NotificationDbTester.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/notification/NotificationDbTester.java @@ -21,7 +21,7 @@ package org.sonar.db.notification; import java.util.List; import javax.annotation.Nullable; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; @@ -51,7 +51,7 @@ public class NotificationDbTester { .setUserId((int) userId) .build(), dbSession).stream() .filter(prop -> component == null ? prop.getResourceId() == null : prop.getResourceId() != null) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); assertThat(result).hasSize(1); assertThat(result.get(0).getValue()).isEqualTo("true"); } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserDbTester.java b/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserDbTester.java index c82bcdac7de..41a8bdca090 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserDbTester.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserDbTester.java @@ -25,7 +25,7 @@ import java.util.Optional; import java.util.function.Consumer; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; @@ -296,6 +296,6 @@ public class UserDbTester { return keys .stream() .map(OrganizationPermission::fromKey) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); } } diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/history/MigrationHistoryImpl.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/history/MigrationHistoryImpl.java index f36134be0d7..8d68b01bb1f 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/history/MigrationHistoryImpl.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/history/MigrationHistoryImpl.java @@ -34,7 +34,7 @@ import org.sonar.db.DatabaseUtils; import org.sonar.server.platform.db.migration.step.RegisteredMigrationStep; import static com.google.common.base.Preconditions.checkState; -import static org.sonar.core.util.stream.Collectors.toList; +import static org.sonar.core.util.stream.MoreCollectors.toList; public class MigrationHistoryImpl implements MigrationHistory { private static final String SCHEMA_MIGRATIONS_TABLE = "schema_migrations"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/CreateTableBuilder.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/CreateTableBuilder.java index 89bbbb93d7d..14065476b30 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/CreateTableBuilder.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/CreateTableBuilder.java @@ -29,7 +29,7 @@ import java.util.List; import java.util.Locale; import java.util.stream.Stream; import javax.annotation.CheckForNull; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.dialect.Dialect; import org.sonar.db.dialect.H2; import org.sonar.db.dialect.MsSql; @@ -67,7 +67,7 @@ public class CreateTableBuilder { checkState(!columnDefs.isEmpty() || !pkColumnDefs.isEmpty(), "at least one column must be specified"); return Stream.concat(of(createTableStatement()), createOracleAutoIncrementStatements()) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); } public CreateTableBuilder addColumn(ColumnDef columnDef) { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DropColumnsBuilder.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DropColumnsBuilder.java index e04a78d4816..dce0c61fb8c 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DropColumnsBuilder.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DropColumnsBuilder.java @@ -23,7 +23,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.dialect.Dialect; import org.sonar.db.dialect.H2; import org.sonar.db.dialect.MsSql; @@ -58,7 +58,7 @@ public class DropColumnsBuilder { case Oracle.ID: return Collections.singletonList(getOracleStatement()); case H2.ID: - return Arrays.stream(columns).map(this::getMsSQLStatement).collect(Collectors.toList(columns.length)); + return Arrays.stream(columns).map(this::getMsSQLStatement).collect(MoreCollectors.toList(columns.length)); default: throw new IllegalStateException(String.format("Unsupported database '%s'", dialect.getId())); } diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/step/MigrationStepRegistryImpl.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/step/MigrationStepRegistryImpl.java index 3039819f716..0ae8967c845 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/step/MigrationStepRegistryImpl.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/step/MigrationStepRegistryImpl.java @@ -23,7 +23,7 @@ import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; @@ -54,7 +54,7 @@ public class MigrationStepRegistryImpl implements InternalMigrationStepRegistry return migrations.entrySet().stream() .sorted(Comparator.comparingLong(Map.Entry::getKey)) .map(Map.Entry::getValue) - .collect(Collectors.toList(migrations.size())); + .collect(MoreCollectors.toList(migrations.size())); } } diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DropIssueFiltersTables.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DropIssueFiltersTables.java index eb74bb4992b..43036dd0373 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DropIssueFiltersTables.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DropIssueFiltersTables.java @@ -30,7 +30,7 @@ import org.sonar.db.DatabaseUtils; import org.sonar.server.platform.db.migration.sql.DropTableBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import static org.sonar.core.util.stream.Collectors.toList; +import static org.sonar.core.util.stream.MoreCollectors.toList; public class DropIssueFiltersTables extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DropMeasureFiltersTables.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DropMeasureFiltersTables.java index 829b23d68d2..bb06b58021f 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DropMeasureFiltersTables.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DropMeasureFiltersTables.java @@ -30,7 +30,7 @@ import org.sonar.db.DatabaseUtils; import org.sonar.server.platform.db.migration.sql.DropTableBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import static org.sonar.core.util.stream.Collectors.toList; +import static org.sonar.core.util.stream.MoreCollectors.toList; public class DropMeasureFiltersTables extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DropRelatedDashboardTables.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DropRelatedDashboardTables.java index 3c1236c722d..ad7e563422e 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DropRelatedDashboardTables.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/DropRelatedDashboardTables.java @@ -30,7 +30,7 @@ import org.sonar.db.DatabaseUtils; import org.sonar.server.platform.db.migration.sql.DropTableBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import static org.sonar.core.util.stream.Collectors.toList; +import static org.sonar.core.util.stream.MoreCollectors.toList; public class DropRelatedDashboardTables extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/UpdateQualityGateConditionsOnCoverage.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/UpdateQualityGateConditionsOnCoverage.java index 77f996be513..91ddc1d5105 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/UpdateQualityGateConditionsOnCoverage.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v62/UpdateQualityGateConditionsOnCoverage.java @@ -35,7 +35,7 @@ import org.sonar.server.platform.db.migration.step.DataChange; import org.sonar.server.platform.db.migration.step.Select; import static java.util.Objects.requireNonNull; -import static org.sonar.core.util.stream.Collectors.uniqueIndex; +import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex; import static org.sonar.db.DatabaseUtils.repeatCondition; /** diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v56/PopulateInitialSchemaTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v56/PopulateInitialSchemaTest.java index 444aae7628c..b0c6bcd47a3 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v56/PopulateInitialSchemaTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v56/PopulateInitialSchemaTest.java @@ -26,7 +26,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonar.api.utils.System2; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.CoreDbTester; import static org.assertj.core.api.Assertions.assertThat; @@ -76,7 +76,7 @@ public class PopulateInitialSchemaTest { "from group_roles gr where gr.group_id is null"); List<String> roles = rows.stream() .map(row -> (String) row.get("role")) - .collect(Collectors.toArrayList()); + .collect(MoreCollectors.toArrayList()); assertThat(roles).containsOnly("provisioning", "scan"); } @@ -87,7 +87,7 @@ public class PopulateInitialSchemaTest { "where g.name='" + groupName + "'"); return rows.stream() .map(row -> (String) row.get("role")) - .collect(Collectors.toArrayList()); + .collect(MoreCollectors.toArrayList()); } private void verifyGroup(String expectedName, String expectedDescription) { @@ -106,7 +106,7 @@ public class PopulateInitialSchemaTest { "where u.login='admin'"); List<String> groupNames = rows.stream() .map(row -> (String) row.get("groupName")) - .collect(Collectors.toArrayList()); + .collect(MoreCollectors.toArrayList()); assertThat(groupNames).containsOnly("sonar-administrators", "sonar-users"); } diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/PopulateOrganizationMembersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/PopulateOrganizationMembersTableTest.java index ecb13741caf..4b8df9f7af9 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/PopulateOrganizationMembersTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/PopulateOrganizationMembersTableTest.java @@ -30,7 +30,7 @@ import org.apache.commons.lang.RandomStringUtils; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.CoreDbTester; import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidImpl; @@ -305,7 +305,7 @@ public class PopulateOrganizationMembersTableTest { List<Map<String, Object>> rows = db.select(format("SELECT ORGANIZATION_UUID FROM " + TABLE + " WHERE USER_ID = %s", userId)); List<String> userOrganizationUuids = rows.stream() .map(values -> (String) values.get("ORGANIZATION_UUID")) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); assertThat(userOrganizationUuids).containsOnly(organizationUuids); } diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetCopyComponentUuidOnLocalViewsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetCopyComponentUuidOnLocalViewsTest.java index 82168dc834c..ad9e426328a 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetCopyComponentUuidOnLocalViewsTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v64/SetCopyComponentUuidOnLocalViewsTest.java @@ -30,7 +30,7 @@ import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.junit.Rule; import org.junit.Test; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.CoreDbTester; import static org.assertj.core.api.Assertions.assertThat; @@ -167,12 +167,12 @@ public class SetCopyComponentUuidOnLocalViewsTest { } private void verifyComponentsHavingCopyComponentUuid(Component... expectedComponents) { - Map<String, Component> expectedComponentsByUuid = Arrays.stream(expectedComponents).collect(Collectors.uniqueIndex(Component::getUuid)); + Map<String, Component> expectedComponentsByUuid = Arrays.stream(expectedComponents).collect(MoreCollectors.uniqueIndex(Component::getUuid)); List<Map<String, Object>> rows = db.select("SELECT uuid, copy_component_uuid FROM " + TABLE_PROJECTS + " WHERE copy_component_uuid IS NOT NULL"); Map<String, Component> components = rows.stream() .map(map -> new Component((String) map.get("UUID"), (String) map.get("COPY_COMPONENT_UUID"))) - .collect(Collectors.uniqueIndex(Component::getUuid)); + .collect(MoreCollectors.uniqueIndex(Component::getUuid)); assertThat(components.keySet()).containsExactlyElementsOf(expectedComponentsByUuid.keySet()); components.entrySet().forEach(entry -> { Component expectedComponent = expectedComponentsByUuid.get(entry.getKey()); diff --git a/server/sonar-server/src/main/java/org/sonar/server/authentication/UserIdentityAuthenticator.java b/server/sonar-server/src/main/java/org/sonar/server/authentication/UserIdentityAuthenticator.java index d679ac9c783..04c89c71003 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/authentication/UserIdentityAuthenticator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/authentication/UserIdentityAuthenticator.java @@ -46,7 +46,7 @@ import org.sonar.server.user.UserUpdater; import static java.lang.String.format; import static java.util.Collections.singletonList; -import static org.sonar.core.util.stream.Collectors.uniqueIndex; +import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex; public class UserIdentityAuthenticator { diff --git a/server/sonar-server/src/main/java/org/sonar/server/authentication/event/AuthenticationEventImpl.java b/server/sonar-server/src/main/java/org/sonar/server/authentication/event/AuthenticationEventImpl.java index 58dbd939f86..32cdebc2ad9 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/authentication/event/AuthenticationEventImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/authentication/event/AuthenticationEventImpl.java @@ -25,7 +25,7 @@ import javax.annotation.Nullable; import javax.servlet.http.HttpServletRequest; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import static java.util.Objects.requireNonNull; @@ -47,7 +47,7 @@ public class AuthenticationEventImpl implements AuthenticationEvent { } private static String getAllIps(HttpServletRequest request) { - return Collections.list(request.getHeaders("X-Forwarded-For")).stream().collect(Collectors.join(Joiner.on(","))); + return Collections.list(request.getHeaders("X-Forwarded-For")).stream().collect(MoreCollectors.join(Joiner.on(","))); } @Override diff --git a/server/sonar-server/src/main/java/org/sonar/server/ce/ws/TaskAction.java b/server/sonar-server/src/main/java/org/sonar/server/ce/ws/TaskAction.java index 799c722fbe0..fdc082607ed 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/ce/ws/TaskAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/ce/ws/TaskAction.java @@ -32,7 +32,7 @@ import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; import org.sonar.core.util.Uuids; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.ce.CeActivityDto; @@ -173,13 +173,13 @@ public class TaskAction implements CeWsAction { return null; }) .filter(Objects::nonNull) - .collect(Collectors.toSet()); + .collect(MoreCollectors.toSet()); } public static Collection<String> possibleValues() { return Arrays.stream(values()) .map(AdditionalField::getLabel) - .collect(Collectors.toList(values().length)); + .collect(MoreCollectors.toList(values().length)); } } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/ce/ws/TaskFormatter.java b/server/sonar-server/src/main/java/org/sonar/server/ce/ws/TaskFormatter.java index 245c551121a..c71d472597a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/ce/ws/TaskFormatter.java +++ b/server/sonar-server/src/main/java/org/sonar/server/ce/ws/TaskFormatter.java @@ -31,7 +31,7 @@ import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.sonar.api.utils.DateUtils; import org.sonar.api.utils.System2; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.ce.CeActivityDto; @@ -62,7 +62,7 @@ public class TaskFormatter { public List<WsCe.Task> formatQueue(DbSession dbSession, List<CeQueueDto> dtos) { ComponentDtoCache cache = ComponentDtoCache.forQueueDtos(dbClient, dbSession, dtos); - return dtos.stream().map(input -> formatQueue(input, cache)).collect(Collectors.toList(dtos.size())); + return dtos.stream().map(input -> formatQueue(input, cache)).collect(MoreCollectors.toList(dtos.size())); } public WsCe.Task formatQueue(DbSession dbSession, CeQueueDto dto) { @@ -107,7 +107,7 @@ public class TaskFormatter { ComponentDtoCache cache = ComponentDtoCache.forActivityDtos(dbClient, dbSession, dtos); return dtos.stream() .map(input -> formatActivity(input, cache, null)) - .collect(Collectors.toList(dtos.size())); + .collect(MoreCollectors.toList(dtos.size())); } private static WsCe.Task formatActivity(CeActivityDto dto, ComponentDtoCache componentDtoCache, @Nullable String scannerContext) { @@ -156,7 +156,7 @@ public class TaskFormatter { static ComponentDtoCache forQueueDtos(DbClient dbClient, DbSession dbSession, Collection<CeQueueDto> ceQueueDtos) { Map<String, ComponentDto> componentsByUuid = dbClient.componentDao().selectByUuids(dbSession, uuidOfCeQueueDtos(ceQueueDtos)) .stream() - .collect(Collectors.uniqueIndex(ComponentDto::uuid)); + .collect(MoreCollectors.uniqueIndex(ComponentDto::uuid)); return new ComponentDtoCache(componentsByUuid, buildOrganizationsByUuid(dbClient, dbSession, componentsByUuid)); } @@ -165,7 +165,7 @@ public class TaskFormatter { .filter(Objects::nonNull) .map(CeQueueDto::getComponentUuid) .filter(Objects::nonNull) - .collect(Collectors.toSet(ceQueueDtos.size())); + .collect(MoreCollectors.toSet(ceQueueDtos.size())); } static ComponentDtoCache forActivityDtos(DbClient dbClient, DbSession dbSession, Collection<CeActivityDto> ceActivityDtos) { @@ -173,7 +173,7 @@ public class TaskFormatter { dbSession, uuidOfCeActivityDtos(ceActivityDtos)) .stream() - .collect(Collectors.uniqueIndex(ComponentDto::uuid)); + .collect(MoreCollectors.uniqueIndex(ComponentDto::uuid)); return new ComponentDtoCache(componentsByUuid, buildOrganizationsByUuid(dbClient, dbSession, componentsByUuid)); } @@ -182,7 +182,7 @@ public class TaskFormatter { .filter(Objects::nonNull) .map(CeActivityDto::getComponentUuid) .filter(Objects::nonNull) - .collect(Collectors.toSet(ceActivityDtos.size())); + .collect(MoreCollectors.toSet(ceActivityDtos.size())); } static ComponentDtoCache forUuid(DbClient dbClient, DbSession dbSession, String uuid) { @@ -200,9 +200,9 @@ public class TaskFormatter { dbSession, componentsByUuid.values().stream() .map(ComponentDto::getOrganizationUuid) - .collect(Collectors.toSet(componentsByUuid.size()))) + .collect(MoreCollectors.toSet(componentsByUuid.size()))) .stream() - .collect(Collectors.uniqueIndex(OrganizationDto::getUuid)); + .collect(MoreCollectors.uniqueIndex(OrganizationDto::getUuid)); } @CheckForNull diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ComponentFinder.java b/server/sonar-server/src/main/java/org/sonar/server/component/ComponentFinder.java index b4dc747d242..1054150c3d6 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ComponentFinder.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ComponentFinder.java @@ -25,7 +25,7 @@ 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.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -92,7 +92,7 @@ public class ComponentFinder { Set<String> rootQualifiers = rootTypes .stream() .map(ResourceType::getQualifier) - .collect(Collectors.toSet(rootTypes.size())); + .collect(MoreCollectors.toSet(rootTypes.size())); String qualifier = component.qualifier(); checkRequest(rootQualifiers.contains(qualifier) || Qualifiers.MODULE.equals(qualifier), diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/index/ComponentIndex.java b/server/sonar-server/src/main/java/org/sonar/server/component/index/ComponentIndex.java index 4d9f7af46f0..47564f4d889 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/index/ComponentIndex.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/index/ComponentIndex.java @@ -36,7 +36,7 @@ import org.elasticsearch.search.aggregations.bucket.filters.InternalFilters; import org.elasticsearch.search.aggregations.bucket.filters.InternalFilters.Bucket; import org.elasticsearch.search.aggregations.metrics.tophits.InternalTopHits; import org.elasticsearch.search.aggregations.metrics.tophits.TopHitsBuilder; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.server.es.EsClient; import org.sonar.server.es.textsearch.ComponentTextSearchFeature; import org.sonar.server.es.textsearch.ComponentTextSearchQueryFactory; @@ -116,7 +116,7 @@ public class ComponentIndex { List<Bucket> buckets = filtersAgg.getBuckets(); return buckets.stream() .map(ComponentIndex::bucketToQualifier) - .collect(Collectors.toList(buckets.size())); + .collect(MoreCollectors.toList(buckets.size())); } private static ComponentsPerQualifier bucketToQualifier(Bucket bucket) { @@ -126,7 +126,7 @@ public class ComponentIndex { SearchHit[] hits = hitList.getHits(); List<String> componentUuids = Arrays.stream(hits).map(SearchHit::getId) - .collect(Collectors.toList(hits.length)); + .collect(MoreCollectors.toList(hits.length)); return new ComponentsPerQualifier(bucket.getKey(), componentUuids, hitList.totalHits()); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ws/FilterParser.java b/server/sonar-server/src/main/java/org/sonar/server/component/ws/FilterParser.java index 9a4a3f0219b..04c4852f419 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ws/FilterParser.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ws/FilterParser.java @@ -27,7 +27,7 @@ import java.util.regex.Pattern; import java.util.stream.StreamSupport; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import static com.google.common.base.Strings.isNullOrEmpty; import static java.lang.String.format; @@ -51,7 +51,7 @@ public class FilterParser { public static List<Criterion> parse(String filter) { return StreamSupport.stream(CRITERIA_SPLITTER.split(filter).spliterator(), false) .map(FilterParser::parseCriterion) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); } private static Criterion parseCriterion(String rawCriterion) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ws/ProjectMeasuresQueryValidator.java b/server/sonar-server/src/main/java/org/sonar/server/component/ws/ProjectMeasuresQueryValidator.java index 51118a13380..414cc70770a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ws/ProjectMeasuresQueryValidator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ws/ProjectMeasuresQueryValidator.java @@ -29,8 +29,8 @@ import org.sonar.db.metric.MetricDto; import org.sonar.server.measure.index.ProjectMeasuresQuery; import static com.google.common.base.Preconditions.checkArgument; -import static org.sonar.core.util.stream.Collectors.toHashSet; -import static org.sonar.core.util.stream.Collectors.toSet; +import static org.sonar.core.util.stream.MoreCollectors.toHashSet; +import static org.sonar.core.util.stream.MoreCollectors.toSet; import static org.sonar.server.measure.index.ProjectMeasuresQuery.MetricCriterion; import static org.sonar.server.measure.index.ProjectMeasuresQuery.SORT_BY_NAME; diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/component/ws/SearchAction.java index d9a9dd48a01..5c57fbb2f66 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ws/SearchAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ws/SearchAction.java @@ -32,7 +32,7 @@ import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.utils.Paging; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -48,7 +48,7 @@ import org.sonarqube.ws.client.component.SearchWsRequest; import static com.google.common.base.Preconditions.checkArgument; import static org.sonar.api.web.UserRole.USER; import static org.sonar.core.util.Protobuf.setNullable; -import static org.sonar.core.util.stream.Collectors.uniqueIndex; +import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex; import static org.sonar.server.util.LanguageParamUtils.getExampleValue; import static org.sonar.server.util.LanguageParamUtils.getLanguageKeys; import static org.sonar.server.ws.WsParameterBuilder.createQualifiersParameter; @@ -166,13 +166,13 @@ public class SearchAction implements ComponentsWsAction { // Meanwhile root is explicitly handled. return componentDtos; } - Set<String> projectUuids = componentDtos.stream().map(ComponentDto::projectUuid).collect(Collectors.toSet()); + Set<String> projectUuids = componentDtos.stream().map(ComponentDto::projectUuid).collect(MoreCollectors.toSet()); List<ComponentDto> projects = dbClient.componentDao().selectByUuids(dbSession, projectUuids); Map<String, Long> projectIdsByUuids = projects.stream().collect(uniqueIndex(ComponentDto::uuid, ComponentDto::getId)); Collection<Long> authorizedProjectIds = dbClient.authorizationDao().keepAuthorizedProjectIds(dbSession, projectIdsByUuids.values(), userSession.getUserId(), USER); return componentDtos.stream() .filter(component -> authorizedProjectIds.contains(projectIdsByUuids.get(component.projectUuid()))) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); } private static SearchWsResponse buildResponse(List<ComponentDto> components, OrganizationDto organization, Paging paging) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ws/SearchProjectsAction.java b/server/sonar-server/src/main/java/org/sonar/server/component/ws/SearchProjectsAction.java index fd148a031f9..f4d28bf183e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ws/SearchProjectsAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ws/SearchProjectsAction.java @@ -39,7 +39,7 @@ import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.utils.DateUtils; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -67,7 +67,7 @@ import static java.util.Collections.emptyMap; import static org.sonar.api.measures.CoreMetrics.ALERT_STATUS_KEY; import static org.sonar.api.measures.CoreMetrics.NCLOC_KEY; import static org.sonar.api.server.ws.WebService.Param.FIELDS; -import static org.sonar.core.util.stream.Collectors.toSet; +import static org.sonar.core.util.stream.MoreCollectors.toSet; import static org.sonar.server.component.ws.ProjectMeasuresQueryFactory.IS_FAVORITE_CRITERION; import static org.sonar.server.component.ws.ProjectMeasuresQueryFactory.newProjectMeasuresQuery; import static org.sonar.server.measure.index.ProjectMeasuresIndex.SUPPORTED_FACETS; @@ -201,7 +201,7 @@ public class SearchProjectsAction implements ComponentsWsAction { Set<String> organizationUuids = searchResults.projects.stream().map(ComponentDto::getOrganizationUuid).collect(toSet()); Map<String, OrganizationDto> organizationsByUuid = dbClient.organizationDao().selectByUuids(dbSession, organizationUuids) .stream() - .collect(Collectors.uniqueIndex(OrganizationDto::getUuid)); + .collect(MoreCollectors.uniqueIndex(OrganizationDto::getUuid)); return buildResponse(request, searchResults, organizationsByUuid); } @@ -253,20 +253,20 @@ public class SearchProjectsAction implements ComponentsWsAction { List<Long> favoriteDbIds = props.stream() .map(PropertyDto::getResourceId) - .collect(Collectors.toList(props.size())); + .collect(MoreCollectors.toList(props.size())); return dbClient.componentDao().selectByIds(dbSession, favoriteDbIds).stream() .filter(ComponentDto::isEnabled) .filter(f -> f.qualifier().equals(Qualifiers.PROJECT)) .map(ComponentDto::uuid) - .collect(Collectors.toSet()); + .collect(MoreCollectors.toSet()); } private Map<String, SnapshotDto> getSnapshots(DbSession dbSession, SearchProjectsRequest request, List<String> projectUuids) { if (request.getAdditionalFields().contains(ANALYSIS_DATE)) { return dbClient.snapshotDao().selectLastAnalysesByRootComponentUuids(dbSession, projectUuids) .stream() - .collect(Collectors.uniqueIndex(SnapshotDto::getComponentUuid)); + .collect(MoreCollectors.uniqueIndex(SnapshotDto::getComponentUuid)); } return emptyMap(); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ws/SuggestionsAction.java b/server/sonar-server/src/main/java/org/sonar/server/component/ws/SuggestionsAction.java index efc9671ebc0..37801d92205 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ws/SuggestionsAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ws/SuggestionsAction.java @@ -30,7 +30,7 @@ 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.server.ws.WebService.NewAction; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -124,13 +124,13 @@ public class SuggestionsAction implements ComponentsWsAction { List<Component> results = sortedComponentDtos .stream() .map(dto -> dtoToComponent(dto, organizationKeyByUuids)) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); return Qualifier.newBuilder() .setQ(qualifier.getQualifier()) .addAllItems(results) .build(); - }).collect(Collectors.toList()); + }).collect(MoreCollectors.toList()); } } @@ -138,9 +138,9 @@ public class SuggestionsAction implements ComponentsWsAction { private Map<String, String> getOrganizationKeys(DbSession dbSession, List<ComponentDto> componentDtos) { return dbClient.organizationDao().selectByUuids( dbSession, - componentDtos.stream().map(ComponentDto::getOrganizationUuid).collect(Collectors.toSet())) + componentDtos.stream().map(ComponentDto::getOrganizationUuid).collect(MoreCollectors.toSet())) .stream() - .collect(Collectors.uniqueIndex(OrganizationDto::getUuid, OrganizationDto::getKey)); + .collect(MoreCollectors.uniqueIndex(OrganizationDto::getUuid, OrganizationDto::getKey)); } private List<ComponentsPerQualifier> searchInIndex(ComponentIndexQuery componentIndexQuery) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ws/TreeAction.java b/server/sonar-server/src/main/java/org/sonar/server/component/ws/TreeAction.java index c5b0a8254cf..aa67d804a53 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ws/TreeAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ws/TreeAction.java @@ -40,7 +40,7 @@ import org.sonar.api.server.ws.WebService; import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.utils.Paging; import org.sonar.api.web.UserRole; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -186,13 +186,13 @@ public class TreeAction implements ComponentsWsAction { List<String> referenceComponentIds = components.stream() .map(ComponentDto::getCopyResourceUuid) .filter(Objects::nonNull) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); if (referenceComponentIds.isEmpty()) { return emptyMap(); } return dbClient.componentDao().selectByUuids(dbSession, referenceComponentIds).stream() - .collect(Collectors.uniqueIndex(ComponentDto::uuid)); + .collect(MoreCollectors.uniqueIndex(ComponentDto::uuid)); } private void checkPermissions(ComponentDto baseComponent) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/queue/PurgeCeActivities.java b/server/sonar-server/src/main/java/org/sonar/server/computation/queue/PurgeCeActivities.java index e709736e56d..1621fadc177 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/queue/PurgeCeActivities.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/queue/PurgeCeActivities.java @@ -27,7 +27,7 @@ import org.sonar.api.platform.ServerStartHandler; import org.sonar.api.utils.System2; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.ce.CeActivityDto; @@ -56,7 +56,7 @@ public class PurgeCeActivities implements ServerStartHandler { Set<String> ceActivityUuids = dbClient.ceActivityDao().selectOlderThan(dbSession, sixMonthsAgo.getTimeInMillis()) .stream() .map(CeActivityDto::getUuid) - .collect(Collectors.toSet()); + .collect(MoreCollectors.toSet()); dbClient.ceActivityDao().deleteByUuids(dbSession, ceActivityUuids); dbClient.ceScannerContextDao().deleteByUuids(dbSession, ceActivityUuids); dbSession.commit(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/ComponentRootBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/ComponentRootBuilder.java index 8bb9554698b..ab731524c02 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/ComponentRootBuilder.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/ComponentRootBuilder.java @@ -36,7 +36,7 @@ import static java.lang.String.format; import static org.apache.commons.lang.StringUtils.trimToNull; import static org.sonar.core.component.ComponentKeys.createEffectiveKey; import static org.sonar.core.component.ComponentKeys.createKey; -import static org.sonar.core.util.stream.Collectors.toList; +import static org.sonar.core.util.stream.MoreCollectors.toList; public class ComponentRootBuilder { private static final String DEFAULT_PROJECT_VERSION = "not provided"; diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitygate/QualityGateServiceImpl.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitygate/QualityGateServiceImpl.java index a9b4ee85bc4..a524141097c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitygate/QualityGateServiceImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitygate/QualityGateServiceImpl.java @@ -21,7 +21,7 @@ package org.sonar.server.computation.task.projectanalysis.qualitygate; import com.google.common.base.Optional; import java.util.Collection; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.qualitygate.QualityGateConditionDto; @@ -58,7 +58,7 @@ public class QualityGateServiceImpl implements QualityGateService { Metric metric = metricRepository.getById(input.getMetricId()); return new Condition(metric, input.getOperator(), input.getErrorThreshold(), input.getWarningThreshold(), input.getPeriod() != null); }) - .collect(Collectors.toList(dtos.size())); + .collect(MoreCollectors.toList(dtos.size())); return new QualityGate(qualityGateDto.getId(), qualityGateDto.getName(), conditions); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/scm/DbScmInfo.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/scm/DbScmInfo.java index 5f14e0e06b2..64c958d0dc6 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/scm/DbScmInfo.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/scm/DbScmInfo.java @@ -29,7 +29,7 @@ import java.util.stream.StreamSupport; import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.concurrent.Immutable; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.protobuf.DbFileSources; import org.sonar.server.computation.task.projectanalysis.component.Component; @@ -52,7 +52,7 @@ class DbScmInfo implements ScmInfo { List<Changeset> lineChangesets = StreamSupport.stream(lines.spliterator(), false) .map(lineToChangeset) .filter(Objects::nonNull) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); if (lineChangesets.isEmpty()) { return Optional.absent(); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/ComputeMeasureVariationsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/ComputeMeasureVariationsStep.java index 074fc983bf4..7bb05b4f25e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/ComputeMeasureVariationsStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/ComputeMeasureVariationsStep.java @@ -29,7 +29,7 @@ import java.util.function.Predicate; import java.util.stream.StreamSupport; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.measure.PastMeasureDto; @@ -50,7 +50,7 @@ import org.sonar.server.computation.task.step.ComputationStep; import static com.google.common.base.Preconditions.checkArgument; import static java.lang.String.format; import static java.util.function.Function.identity; -import static org.sonar.core.util.stream.Collectors.uniqueIndex; +import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex; import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.DIRECTORY; import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.SUBVIEW; import static org.sonar.server.computation.task.projectanalysis.component.ComponentVisitor.Order.PRE_ORDER; @@ -81,7 +81,7 @@ public class ComputeMeasureVariationsStep implements ComputationStep { @Override public void execute() { try (DbSession dbSession = dbClient.openSession(false)) { - List<Metric> metrics = StreamSupport.stream(metricRepository.getAll().spliterator(), false).filter(isNumeric()).collect(Collectors.toList()); + List<Metric> metrics = StreamSupport.stream(metricRepository.getAll().spliterator(), false).filter(isNumeric()).collect(MoreCollectors.toList()); new DepthTraversalTypeAwareCrawler(new VariationMeasuresVisitor(dbSession, metrics)) .visit(treeRootHolder.getRoot()); } @@ -97,7 +97,7 @@ public class ComputeMeasureVariationsStep implements ComputationStep { // measures on files are currently purged, so past measures are not available on files super(CrawlerDepthLimit.reportMaxDepth(DIRECTORY).withViewsMaxDepth(SUBVIEW), PRE_ORDER); this.session = session; - this.metricIds = metrics.stream().map(Metric::getId).collect(Collectors.toSet()); + this.metricIds = metrics.stream().map(Metric::getId).collect(MoreCollectors.toSet()); this.metrics = metrics; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/LoadReportAnalysisMetadataHolderStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/LoadReportAnalysisMetadataHolderStep.java index 9fc337e9453..fd8f7cb451d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/LoadReportAnalysisMetadataHolderStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/LoadReportAnalysisMetadataHolderStep.java @@ -27,7 +27,7 @@ import java.util.Optional; import javax.annotation.Nullable; import org.sonar.api.utils.MessageException; import org.sonar.ce.queue.CeTask; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.organization.OrganizationDto; @@ -45,7 +45,7 @@ import static com.google.common.base.Preconditions.checkState; import static com.google.common.collect.Maps.transformValues; import static java.lang.String.format; import static org.apache.commons.lang.StringUtils.isNotEmpty; -import static org.sonar.core.util.stream.Collectors.toList; +import static org.sonar.core.util.stream.MoreCollectors.toList; /** * Feed analysis metadata holder with metadata from the analysis report. @@ -105,7 +105,7 @@ public class LoadReportAnalysisMetadataHolderStep implements ComputationStep { String badKeys = profiles.stream() .filter(p -> !p.getOrganizationUuid().equals(organization.getUuid())) .map(QualityProfileDto::getKey) - .collect(Collectors.join(Joiner.on(", "))); + .collect(MoreCollectors.join(Joiner.on(", "))); if (!badKeys.isEmpty()) { throw MessageException.of(format("Quality profiles with following keys don't exist in organization [%s]: %s", organization.getKey(), badKeys)); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PersistComponentsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PersistComponentsStep.java index 6d793c70f9e..c32afa64509 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PersistComponentsStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PersistComponentsStep.java @@ -32,7 +32,7 @@ import org.apache.commons.lang.StringUtils; import org.sonar.api.resources.Qualifiers; import org.sonar.api.resources.Scopes; import org.sonar.api.utils.System2; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -107,7 +107,7 @@ public class PersistComponentsStep implements ComputationStep { Set<String> uuids = dtos.stream() .filter(ComponentDto::isEnabled) .map(ComponentDto::uuid) - .collect(Collectors.toSet(dtos.size())); + .collect(MoreCollectors.toSet(dtos.size())); dbClient.componentDao().updateBEnabledToFalse(dbSession, uuids); disabledComponentsHolder.setUuids(uuids); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateMeasuresStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateMeasuresStep.java index cbae46ada60..97a355feca7 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateMeasuresStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateMeasuresStep.java @@ -33,7 +33,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.apache.commons.lang.StringUtils; import org.sonar.api.measures.CoreMetrics; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.server.computation.task.projectanalysis.component.Component; import org.sonar.server.computation.task.projectanalysis.component.CrawlerDepthLimit; import org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler; @@ -171,7 +171,7 @@ public class QualityGateMeasuresStep implements ComputationStep { } private void updateMeasures(Component project, Set<Condition> conditions, QualityGateDetailsDataBuilder builder) { - Multimap<Metric, Condition> conditionsPerMetric = conditions.stream().collect(Collectors.index(Condition::getMetric, java.util.function.Function.identity())); + Multimap<Metric, Condition> conditionsPerMetric = conditions.stream().collect(MoreCollectors.index(Condition::getMetric, java.util.function.Function.identity())); for (Map.Entry<Metric, Collection<Condition>> entry : conditionsPerMetric.asMap().entrySet()) { Metric metric = entry.getKey(); Optional<Measure> measure = measureRepository.getRawMeasure(project, metric); diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/webhook/WebhookPostTask.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/webhook/WebhookPostTask.java index 5dbae13a8c9..6baef99868a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/webhook/WebhookPostTask.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/webhook/WebhookPostTask.java @@ -28,7 +28,7 @@ import org.sonar.api.config.Settings; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; import org.sonar.core.config.WebhookProperties; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.server.computation.task.projectanalysis.component.SettingsRepository; import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolder; @@ -72,7 +72,7 @@ public class WebhookPostTask implements PostProjectAnalysisTask { return Arrays.stream(webhookIds) .map(webhookId -> format("%s.%s", propertyKey, webhookId)) .limit(MAX_WEBHOOKS_PER_TYPE) - .collect(Collectors.toList(webhookIds.length)); + .collect(MoreCollectors.toList(webhookIds.length)); } private void process(Settings settings, ProjectAnalysis analysis, Iterable<String> webhookProperties) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/EsUtils.java b/server/sonar-server/src/main/java/org/sonar/server/es/EsUtils.java index 537354afe32..22e263428ce 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/es/EsUtils.java +++ b/server/sonar-server/src/main/java/org/sonar/server/es/EsUtils.java @@ -41,7 +41,7 @@ import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.SearchHits; import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.joda.time.format.ISODateTimeFormat; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import static java.lang.String.format; @@ -78,7 +78,7 @@ public class EsUtils { public static List<String> termsKeys(Terms terms) { return terms.getBuckets().stream() .map(Terms.Bucket::getKeyAsString) - .collect(Collectors.toList(terms.getBuckets().size())); + .collect(MoreCollectors.toList(terms.getBuckets().size())); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/IndexType.java b/server/sonar-server/src/main/java/org/sonar/server/es/IndexType.java index cb61216cd84..4ead86465ef 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/es/IndexType.java +++ b/server/sonar-server/src/main/java/org/sonar/server/es/IndexType.java @@ -21,7 +21,7 @@ package org.sonar.server.es; import java.util.Arrays; import java.util.function.Function; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import static java.util.Objects.requireNonNull; @@ -52,7 +52,7 @@ public class IndexType { } private static String[] getDetails(Function<? super IndexType, ? extends String> function, IndexType... indexTypes) { - return Arrays.stream(indexTypes).map(function).collect(Collectors.toSet(indexTypes.length)).toArray(new String[0]); + return Arrays.stream(indexTypes).map(function).collect(MoreCollectors.toSet(indexTypes.length)).toArray(new String[0]); } @Override diff --git a/server/sonar-server/src/main/java/org/sonar/server/favorite/FavoriteFinder.java b/server/sonar-server/src/main/java/org/sonar/server/favorite/FavoriteFinder.java index b3c177274e3..b2bb23b0482 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/favorite/FavoriteFinder.java +++ b/server/sonar-server/src/main/java/org/sonar/server/favorite/FavoriteFinder.java @@ -31,7 +31,7 @@ import org.sonar.db.property.PropertyQuery; import org.sonar.server.user.UserSession; import static java.util.Collections.emptyList; -import static org.sonar.core.util.stream.Collectors.toList; +import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.server.favorite.FavoriteUpdater.PROP_FAVORITE_KEY; public class FavoriteFinder { diff --git a/server/sonar-server/src/main/java/org/sonar/server/favorite/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/favorite/ws/SearchAction.java index 950da42af2f..b94c6470baa 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/favorite/ws/SearchAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/favorite/ws/SearchAction.java @@ -30,7 +30,7 @@ import org.sonar.api.server.ws.WebService; import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.utils.Paging; import org.sonar.api.web.UserRole; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -90,12 +90,12 @@ public class SearchAction implements FavoritesWsAction { try (DbSession dbSession = dbClient.openSession(false)) { List<ComponentDto> authorizedFavorites = favoriteFinder.list().stream() .filter(isAuthorized(dbSession)) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); Paging paging = Paging.forPageIndex(request.getPage()).withPageSize(request.getPageSize()).andTotal(authorizedFavorites.size()); List<ComponentDto> displayedFavorites = authorizedFavorites.stream() .skip(paging.offset()) .limit(paging.pageSize()) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); Map<String, OrganizationDto> organizationsByUuid = getOrganizationsOfComponents(dbSession, displayedFavorites); return new SearchResults(paging, displayedFavorites, organizationsByUuid); } @@ -105,17 +105,17 @@ public class SearchAction implements FavoritesWsAction { Collection<String> rootProjectsUuids = dbClient.authorizationDao().selectAuthorizedRootProjectsUuids(dbSession, userSession.getUserId(), UserRole.USER); Set<String> authorizedProjectUuids = rootProjectsUuids .stream() - .collect(Collectors.toSet(rootProjectsUuids.size())); + .collect(MoreCollectors.toSet(rootProjectsUuids.size())); return dto -> authorizedProjectUuids.contains(dto.projectUuid()); } private Map<String, OrganizationDto> getOrganizationsOfComponents(DbSession dbSession, List<ComponentDto> displayedFavorites) { Set<String> organizationUuids = displayedFavorites.stream() .map(ComponentDto::getOrganizationUuid) - .collect(Collectors.toSet()); + .collect(MoreCollectors.toSet()); return dbClient.organizationDao().selectByUuids(dbSession, organizationUuids) .stream() - .collect(Collectors.uniqueIndex(OrganizationDto::getUuid)); + .collect(MoreCollectors.uniqueIndex(OrganizationDto::getUuid)); } private static class SearchResults { diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueFieldsSetter.java b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueFieldsSetter.java index 2a2b2434c47..725d93d036a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueFieldsSetter.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueFieldsSetter.java @@ -37,7 +37,7 @@ import org.sonar.api.utils.Duration; import org.sonar.core.issue.DefaultIssue; import org.sonar.core.issue.DefaultIssueComment; import org.sonar.core.issue.IssueChangeContext; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.user.UserDto; import static com.google.common.base.Preconditions.checkState; @@ -316,7 +316,7 @@ public class IssueFieldsSetter { .filter(Objects::nonNull) .filter(tag -> !tag.isEmpty()) .map(tag -> RuleTagFormat.validate(tag.toLowerCase(Locale.ENGLISH))) - .collect(Collectors.toSet()); + .collect(MoreCollectors.toSet()); Set<String> oldTags = Sets.newHashSet(issue.tags()); if (!oldTags.equals(newTags)) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryFactory.java b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryFactory.java index 1d18c7731f8..43f8cbedae0 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryFactory.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryFactory.java @@ -45,7 +45,7 @@ import org.sonar.api.rule.RuleKey; import org.sonar.api.server.ServerSide; import org.sonar.api.utils.System2; import org.sonar.api.web.UserRole; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -283,7 +283,7 @@ public class IssueQueryFactory { return; } - Set<String> qualifiers = components.stream().map(ComponentDto::qualifier).collect(Collectors.toHashSet()); + Set<String> qualifiers = components.stream().map(ComponentDto::qualifier).collect(MoreCollectors.toHashSet()); if (qualifiers.size() > 1) { throw new IllegalArgumentException("All components must have the same qualifier, found " + Joiner.on(',').join(qualifiers)); } @@ -337,7 +337,7 @@ public class IssueQueryFactory { } private Collection<String> convertComponentKeysToUuids(DbSession dbSession, Collection<String> componentKeys) { - List<String> componentUuids = dbClient.componentDao().selectByKeys(dbSession, componentKeys).stream().map(ComponentDto::uuid).collect(Collectors.toList()); + List<String> componentUuids = dbClient.componentDao().selectByKeys(dbSession, componentKeys).stream().map(ComponentDto::uuid).collect(MoreCollectors.toList()); // If unknown components are given, but no components are found, then all issues will be returned, // so we add this hack in order to return no issue in this case. if (!componentKeys.isEmpty() && componentUuids.isEmpty()) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/TransitionAction.java b/server/sonar-server/src/main/java/org/sonar/server/issue/TransitionAction.java index c0c57be6a59..d88c80aedb2 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/TransitionAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/TransitionAction.java @@ -23,7 +23,7 @@ import java.util.Collection; import java.util.Map; import org.sonar.api.server.ServerSide; import org.sonar.core.issue.DefaultIssue; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.server.issue.workflow.Transition; import org.sonar.server.user.UserSession; @@ -60,7 +60,7 @@ public class TransitionAction extends Action { return transitionService.listTransitions(issue) .stream() .map(Transition::key) - .collect(Collectors.toSet()) + .collect(MoreCollectors.toSet()) .contains(transitionKey); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/TransitionService.java b/server/sonar-server/src/main/java/org/sonar/server/issue/TransitionService.java index ce29c8ebf95..7a441c1e4a3 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/TransitionService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/TransitionService.java @@ -22,7 +22,7 @@ package org.sonar.server.issue; import java.util.List; import org.sonar.core.issue.DefaultIssue; import org.sonar.core.issue.IssueChangeContext; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.server.issue.workflow.IssueWorkflow; import org.sonar.server.issue.workflow.Transition; import org.sonar.server.user.UserSession; @@ -50,7 +50,7 @@ public class TransitionService { .stream() .filter(transition -> (userSession.isLoggedIn() && isBlank(transition.requiredProjectPermission())) || userSession.hasComponentUuidPermission(transition.requiredProjectPermission(), projectUuid)) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); } public boolean doTransition(DefaultIssue defaultIssue, IssueChangeContext issueChangeContext, String transitionKey) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndex.java b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndex.java index a97346655d4..0f1c7d06d56 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndex.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndex.java @@ -65,7 +65,7 @@ import org.sonar.api.resources.Scopes; import org.sonar.api.utils.DateUtils; import org.sonar.api.utils.System2; import org.sonar.core.util.NonNullInputFunction; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.component.ComponentDto; import org.sonar.server.es.EsClient; import org.sonar.server.es.EsUtils; @@ -529,7 +529,7 @@ public class IssueIndex { if (values == null) { return Collections.emptyList(); } - return values.stream().map(Pattern::quote).collect(Collectors.toArrayList(values.size())); + return values.stream().map(Pattern::quote).collect(MoreCollectors.toArrayList(values.size())); } private void addAssignedToMeFacetIfNeeded(SearchRequestBuilder builder, SearchOptions options, IssueQuery query, Map<String, QueryBuilder> filters, QueryBuilder queryBuilder) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/BulkChangeAction.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/BulkChangeAction.java index 4ca1f97cb40..dc51adcc989 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/BulkChangeAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/BulkChangeAction.java @@ -45,7 +45,7 @@ import org.sonar.api.utils.log.Loggers; import org.sonar.api.web.UserRole; import org.sonar.core.issue.DefaultIssue; import org.sonar.core.issue.IssueChangeContext; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -70,8 +70,8 @@ import static org.sonar.api.rule.Severity.BLOCKER; import static org.sonar.api.rules.RuleType.BUG; 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.Collectors.toList; -import static org.sonar.core.util.stream.Collectors.uniqueIndex; +import static org.sonar.core.util.stream.MoreCollectors.toList; +import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex; import static org.sonar.server.es.SearchOptions.MAX_LIMIT; import static org.sonar.server.issue.AbstractChangeTagsAction.TAGS_PARAMETER; import static org.sonar.server.issue.AssignAction.ASSIGNEE_PARAMETER; @@ -184,7 +184,7 @@ public class BulkChangeAction implements IssuesWsAction { .map(loadData(dbSession)) .map(executeBulkChange()) .map(toWsResponse()) - .collect(Collectors.toOneElement()); + .collect(MoreCollectors.toOneElement()); writeProtobuf(wsResponse, request, response); } } @@ -200,7 +200,7 @@ public class BulkChangeAction implements IssuesWsAction { List<DefaultIssue> items = bulkChangeData.issues.stream() .filter(bulkChange(issueChangeContext, bulkChangeData, result)) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); issueStorage.save(items); items.forEach(sendNotification(issueChangeContext, bulkChangeData)); return result; @@ -301,20 +301,20 @@ public class BulkChangeAction implements IssuesWsAction { checkArgument(issueKeys.size() <= MAX_LIMIT, "Number of issues is limited to %s", MAX_LIMIT); List<IssueDto> allIssues = dbClient.issueDao().selectByKeys(dbSession, issueKeys); - List<ComponentDto> allProjects = getComponents(dbSession, allIssues.stream().map(IssueDto::getProjectUuid).collect(Collectors.toSet())); + List<ComponentDto> allProjects = getComponents(dbSession, allIssues.stream().map(IssueDto::getProjectUuid).collect(MoreCollectors.toSet())); this.projectsByUuid = getAuthorizedProjects(dbSession, allProjects).stream().collect(uniqueIndex(ComponentDto::uuid, identity())); this.issues = getAuthorizedIssues(allIssues); this.componentsByUuid = getComponents(dbSession, - issues.stream().map(DefaultIssue::componentUuid).collect(Collectors.toSet())).stream() + issues.stream().map(DefaultIssue::componentUuid).collect(MoreCollectors.toSet())).stream() .collect(uniqueIndex(ComponentDto::uuid, identity())); this.rulesByKey = dbClient.ruleDao().selectDefinitionByKeys(dbSession, - issues.stream().map(DefaultIssue::ruleKey).collect(Collectors.toSet())).stream() + issues.stream().map(DefaultIssue::ruleKey).collect(MoreCollectors.toSet())).stream() .collect(uniqueIndex(RuleDefinitionDto::getKey, identity())); this.availableActions = actions.stream() .filter(action -> propertiesByActions.containsKey(action.key())) .filter(action -> action.verify(getProperties(action.key()), issues, userSession)) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); } private List<ComponentDto> getComponents(DbSession dbSession, Collection<String> componentUuids) { @@ -328,15 +328,15 @@ public class BulkChangeAction implements IssuesWsAction { userSession.getUserId(), UserRole.USER); return projectDtos.stream() .filter(project -> authorizedProjectIds.contains(projectIdsByUuids.get(project.projectUuid()))) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); } private List<DefaultIssue> getAuthorizedIssues(List<IssueDto> allIssues) { - Set<String> projectUuids = projectsByUuid.values().stream().map(ComponentDto::uuid).collect(Collectors.toSet()); + Set<String> projectUuids = projectsByUuid.values().stream().map(ComponentDto::uuid).collect(MoreCollectors.toSet()); return allIssues.stream() .filter(issue -> projectUuids.contains(issue.getProjectUuid())) .map(IssueDto::toDefaultIssue) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); } Map<String, Object> getProperties(String actionKey) { @@ -344,7 +344,7 @@ public class BulkChangeAction implements IssuesWsAction { } List<Action> getActionsWithoutComment() { - return availableActions.stream().filter(action -> !action.key().equals(COMMENT_KEY)).collect(Collectors.toList()); + return availableActions.stream().filter(action -> !action.key().equals(COMMENT_KEY)).collect(MoreCollectors.toList()); } Optional<Action> getCommentAction() { diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/ChangelogAction.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/ChangelogAction.java index 3809f366712..d3a392af1f5 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/ChangelogAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/ChangelogAction.java @@ -32,7 +32,7 @@ import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; import org.sonar.core.issue.FieldDiffs; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -87,7 +87,7 @@ public class ChangelogAction implements IssuesWsAction { ChangelogWsResponse wsResponse = Stream.of(request) .map(searchChangelog(dbSession)) .map(buildResponse()) - .collect(Collectors.toOneElement()); + .collect(MoreCollectors.toOneElement()); writeProtobuf(wsResponse, request, response); } } @@ -100,7 +100,7 @@ public class ChangelogAction implements IssuesWsAction { return result -> Stream.of(ChangelogWsResponse.newBuilder()) .peek(addChanges(result)) .map(ChangelogWsResponse.Builder::build) - .collect(Collectors.toOneElement()); + .collect(MoreCollectors.toOneElement()); } private Consumer<ChangelogWsResponse.Builder> addChanges(ChangeLogResults results) { @@ -153,16 +153,16 @@ public class ChangelogAction implements IssuesWsAction { ChangeLogResults(DbSession dbSession, String issueKey) { IssueDto dbIssue = issueFinder.getByKey(dbSession, issueKey); this.changes = dbClient.issueChangeDao().selectChangelogByIssue(dbSession, dbIssue.getKey()); - List<String> logins = changes.stream().filter(change -> change.userLogin() != null).map(FieldDiffs::userLogin).collect(Collectors.toList()); - this.users = dbClient.userDao().selectByLogins(dbSession, logins).stream().collect(Collectors.uniqueIndex(UserDto::getLogin)); - this.files = dbClient.componentDao().selectByUuids(dbSession, getFileUuids(changes)).stream().collect(Collectors.uniqueIndex(ComponentDto::uuid, Function.identity())); + List<String> logins = changes.stream().filter(change -> change.userLogin() != null).map(FieldDiffs::userLogin).collect(MoreCollectors.toList()); + this.users = dbClient.userDao().selectByLogins(dbSession, logins).stream().collect(MoreCollectors.uniqueIndex(UserDto::getLogin)); + this.files = dbClient.componentDao().selectByUuids(dbSession, getFileUuids(changes)).stream().collect(MoreCollectors.uniqueIndex(ComponentDto::uuid, Function.identity())); } private Set<String> getFileUuids(List<FieldDiffs> changes) { return changes.stream() .filter(diffs -> diffs.diffs().containsKey(FILE)) .flatMap(diffs -> Stream.of(diffs.get(FILE).newValue().toString(), diffs.get(FILE).oldValue().toString())) - .collect(Collectors.toSet()); + .collect(MoreCollectors.toSet()); } @CheckForNull diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/DeleteCommentAction.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/DeleteCommentAction.java index f8a1720265e..613a097e063 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/DeleteCommentAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/DeleteCommentAction.java @@ -27,7 +27,7 @@ import java.util.stream.Stream; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.issue.IssueChangeDto; @@ -83,7 +83,7 @@ public class DeleteCommentAction implements IssuesWsAction { IssueDto issueDto = Stream.of(request) .map(loadCommentData(dbSession)) .peek(deleteComment(dbSession)) - .collect(Collectors.toOneElement()) + .collect(MoreCollectors.toOneElement()) .getIssueDto(); responseWriter.write(issueDto.getKey(), request, response); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/EditCommentAction.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/EditCommentAction.java index df1248790bb..d69c349c144 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/EditCommentAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/EditCommentAction.java @@ -28,7 +28,7 @@ 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.utils.System2; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.issue.IssueChangeDto; @@ -94,7 +94,7 @@ public class EditCommentAction implements IssuesWsAction { .map(toWsRequest()) .map(loadCommentData(dbSession)) .peek(updateComment(dbSession)) - .collect(Collectors.toOneElement()) + .collect(MoreCollectors.toOneElement()) .getIssueDto(); responseWriter.write(issueDto.getKey(), request, response); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java index eb46fdecc6f..9e9a82711dd 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java @@ -37,7 +37,7 @@ import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.utils.Paging; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.server.es.Facets; import org.sonar.server.es.SearchOptions; import org.sonar.server.es.SearchResult; @@ -308,7 +308,7 @@ public class SearchAction implements IssuesWsAction { // execute request SearchResult<IssueDoc> result = issueIndex.search(query, options); - List<String> issueKeys = result.getDocs().stream().map(IssueDoc::key).collect(Collectors.toList(result.getDocs().size())); + List<String> issueKeys = result.getDocs().stream().map(IssueDoc::key).collect(MoreCollectors.toList(result.getDocs().size())); // load the additional information to be returned in response SearchResponseLoader.Collector collector = new SearchResponseLoader.Collector(additionalFields, issueKeys); diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java index 69198d4bec2..e0f16181d98 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java @@ -29,7 +29,7 @@ import java.util.Map; import java.util.Set; import javax.annotation.Nullable; import org.sonar.core.issue.DefaultIssue; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -135,7 +135,7 @@ public class SearchResponseLoader { } dbClient.organizationDao().selectByUuids( dbSession, - components.stream().map(ComponentDto::getOrganizationUuid).collect(Collectors.toSet())) + components.stream().map(ComponentDto::getOrganizationUuid).collect(MoreCollectors.toSet())) .forEach(result::addOrganization); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/license/ws/ListAction.java b/server/sonar-server/src/main/java/org/sonar/server/license/ws/ListAction.java index 7d8a6762799..69cd1f677ee 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/license/ws/ListAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/license/ws/ListAction.java @@ -34,7 +34,7 @@ import org.sonar.api.config.PropertyDefinitions; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.server.setting.ws.Setting; @@ -47,7 +47,7 @@ import org.sonarqube.ws.Licenses.ListWsResponse; import static com.google.common.base.Strings.isNullOrEmpty; import static org.sonar.api.CoreProperties.PERMANENT_SERVER_ID; import static org.sonar.api.PropertyType.LICENSE; -import static org.sonar.core.util.stream.Collectors.uniqueIndex; +import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex; import static org.sonar.server.ws.WsUtils.writeProtobuf; import static org.sonarqube.ws.client.license.LicensesWsParameters.ACTION_LIST; @@ -90,7 +90,7 @@ public class ListAction implements WsAction { private ListWsResponse doHandle(DbSession dbSession) { Map<String, PropertyDefinition> licenseDefinitionsByKeys = definitions.getAll().stream() .filter(definition -> LICENSE.equals(definition.type())) - .collect(Collectors.uniqueIndex(PropertyDefinition::key, Function.identity())); + .collect(MoreCollectors.uniqueIndex(PropertyDefinition::key, Function.identity())); Set<String> settingsKeys = new HashSet<>(licenseDefinitionsByKeys.keySet()); settingsKeys.add(PERMANENT_SERVER_ID); List<Setting> settings = settingsFinder.loadGlobalSettings(dbSession, settingsKeys); diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresDoc.java b/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresDoc.java index 01f9ddbf741..c1738c3dd08 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresDoc.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresDoc.java @@ -27,7 +27,7 @@ import java.util.List; import java.util.Map; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.server.es.BaseDoc; import static org.sonar.api.measures.Metric.Level.ERROR; @@ -124,7 +124,7 @@ public class ProjectMeasuresDoc extends BaseDoc { .map(entry -> ImmutableMap.<String, Object>of( FIELD_MEASURES_KEY, entry.getKey(), FIELD_MEASURES_VALUE, entry.getValue())) - .collect(Collectors.toList())); + .collect(MoreCollectors.toList())); return this; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java b/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java index b62c5ddee27..f50053693ae 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java @@ -41,7 +41,7 @@ import org.elasticsearch.search.aggregations.bucket.range.RangeBuilder; import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.elasticsearch.search.aggregations.bucket.terms.TermsBuilder; import org.elasticsearch.search.sort.FieldSortBuilder; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.server.es.DefaultIndexSettingsElement; import org.sonar.server.es.EsClient; import org.sonar.server.es.SearchIdResult; @@ -332,7 +332,7 @@ public class ProjectMeasuresIndex { return aggregation.getBuckets().stream() .map(Bucket::getKeyAsString) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); } @FunctionalInterface diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentAction.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentAction.java index ad0c597df08..0aff113cd62 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentAction.java @@ -37,7 +37,7 @@ 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.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -230,7 +230,7 @@ public class ComponentAction implements MeasuresWsAction { List<MetricDtoWithBestValue> metricWithBestValueList = metrics.stream() .filter(MetricDtoFunctions.isOptimizedForBestValue()) .map(new MetricDtoToMetricDtoWithBestValueFunction()) - .collect(Collectors.toList(metrics.size())); + .collect(MoreCollectors.toList(metrics.size())); Map<Integer, MeasureDto> measuresByMetricId = Maps.uniqueIndex(measures, MeasureDto::getMetricId); for (MetricDtoWithBestValue metricWithBestValue : metricWithBestValueList) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeDataLoader.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeDataLoader.java index 47bc1cc7657..8b7bc9729b5 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeDataLoader.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeDataLoader.java @@ -45,7 +45,7 @@ import javax.annotation.Nullable; import org.sonar.api.resources.Qualifiers; import org.sonar.api.resources.ResourceTypes; import org.sonar.api.web.UserRole; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -137,7 +137,7 @@ public class ComponentTreeDataLoader { List<String> referenceComponentUUids = components.stream() .map(ComponentDto::getCopyResourceUuid) .filter(Objects::nonNull) - .collect(Collectors.toList(components.size())); + .collect(MoreCollectors.toList(components.size())); if (referenceComponentUUids.isEmpty()) { return emptyMap(); } @@ -207,7 +207,7 @@ public class ComponentTreeDataLoader { List<MetricDtoWithBestValue> metricDtosWithBestValueMeasure = metrics.stream() .filter(MetricDtoFunctions.isOptimizedForBestValue()) .map(new MetricDtoToMetricDtoWithBestValue()) - .collect(Collectors.toList(metrics.size())); + .collect(MoreCollectors.toList(metrics.size())); if (metricDtosWithBestValueMeasure.isEmpty()) { return; } @@ -235,7 +235,7 @@ public class ComponentTreeDataLoader { return components .stream() .filter(new HasMeasure(measuresByComponentUuidAndMetric, metricToSort.get(), wsRequest)) - .collect(Collectors.toList(components.size())); + .collect(MoreCollectors.toList(components.size())); } private static boolean componentWithMeasuresOnly(ComponentTreeWsRequest wsRequest) { @@ -251,7 +251,7 @@ public class ComponentTreeDataLoader { return components.stream() .skip(offset(wsRequest.getPage(), wsRequest.getPageSize())) .limit(wsRequest.getPageSize()) - .collect(Collectors.toList(wsRequest.getPageSize())); + .collect(MoreCollectors.toList(wsRequest.getPageSize())); } @CheckForNull diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/SearchAction.java index 0c1df2aa426..49caf8cf9e5 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/SearchAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/SearchAction.java @@ -30,7 +30,7 @@ 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.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -48,8 +48,8 @@ import static java.util.stream.Collectors.toMap; 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.core.util.stream.Collectors.toList; -import static org.sonar.core.util.stream.Collectors.uniqueIndex; +import static org.sonar.core.util.stream.MoreCollectors.toList; +import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex; import static org.sonar.server.measure.ws.MeasureDtoToWsMeasure.dbToWsMeasure; import static org.sonar.server.measure.ws.MeasuresWsParametersBuilder.createMetricKeysParameter; import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001; @@ -131,7 +131,7 @@ public class SearchAction implements MeasuresWsAction { private List<ComponentDto> searchProjects() { List<ComponentDto> componentDtos = searchByProjectKeys(dbSession, request.getProjectKeys()); - checkArgument(ALLOWED_QUALIFIERS.containsAll(componentDtos.stream().map(ComponentDto::qualifier).collect(Collectors.toSet())), + checkArgument(ALLOWED_QUALIFIERS.containsAll(componentDtos.stream().map(ComponentDto::qualifier).collect(MoreCollectors.toSet())), "Only component of qualifiers %s are allowed", ALLOWED_QUALIFIERS); return getAuthorizedProjects(componentDtos); } @@ -147,7 +147,7 @@ public class SearchAction implements MeasuresWsAction { // Meanwhile root is explicitly handled. return componentDtos; } - Set<String> projectUuids = componentDtos.stream().map(ComponentDto::projectUuid).collect(Collectors.toSet()); + Set<String> projectUuids = componentDtos.stream().map(ComponentDto::projectUuid).collect(MoreCollectors.toSet()); List<ComponentDto> projectDtos = dbClient.componentDao().selectByUuids(dbSession, projectUuids); Map<String, Long> projectIdsByUuids = projectDtos.stream().collect(uniqueIndex(ComponentDto::uuid, ComponentDto::getId)); Set<Long> authorizedProjectIds = dbClient.authorizationDao().keepAuthorizedProjectIds(dbSession, @@ -155,7 +155,7 @@ public class SearchAction implements MeasuresWsAction { userSession.getUserId(), UserRole.USER); return componentDtos.stream() .filter(component -> authorizedProjectIds.contains(projectIdsByUuids.get(component.projectUuid()))) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); } private List<MetricDto> searchMetrics() { diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/SearchHistoryAction.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/SearchHistoryAction.java index 4f8e880ebb2..b916f287e68 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/SearchHistoryAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/SearchHistoryAction.java @@ -30,7 +30,7 @@ import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.web.UserRole; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -121,7 +121,7 @@ public class SearchHistoryAction implements MeasuresWsAction { .map(SearchHistoryAction::toWsRequest) .map(search()) .map(result -> new SearchHistoryResponseFactory(result).apply()) - .collect(Collectors.toOneElement()); + .collect(MoreCollectors.toOneElement()); writeProtobuf(searchHistoryResponse, request, response); } @@ -151,7 +151,7 @@ public class SearchHistoryAction implements MeasuresWsAction { Date to = parseEndingDateOrDateTime(request.getTo()); PastMeasureQuery dbQuery = new PastMeasureQuery( result.getComponent().uuid(), - result.getMetrics().stream().map(MetricDto::getId).collect(Collectors.toList()), + result.getMetrics().stream().map(MetricDto::getId).collect(MoreCollectors.toList()), from == null ? null : from.getTime(), to == null ? null : (to.getTime() + 1_000L)); return dbClient.measureDao().selectPastMeasures(dbSession, dbQuery); @@ -171,8 +171,8 @@ public class SearchHistoryAction implements MeasuresWsAction { private List<MetricDto> searchMetrics(DbSession dbSession, SearchHistoryRequest request) { List<MetricDto> metrics = dbClient.metricDao().selectByKeys(dbSession, request.getMetrics()); if (request.getMetrics().size() > metrics.size()) { - Set<String> requestedMetrics = request.getMetrics().stream().collect(Collectors.toSet()); - Set<String> foundMetrics = metrics.stream().map(MetricDto::getKey).collect(Collectors.toSet()); + Set<String> requestedMetrics = request.getMetrics().stream().collect(MoreCollectors.toSet()); + Set<String> foundMetrics = metrics.stream().map(MetricDto::getKey).collect(MoreCollectors.toSet()); Set<String> unfoundMetrics = Sets.difference(requestedMetrics, foundMetrics).immutableCopy(); throw new IllegalArgumentException(format("Metrics %s are not found", String.join(", ", unfoundMetrics))); diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/SearchHistoryResponseFactory.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/SearchHistoryResponseFactory.java index db7a6ee94a9..3169971a362 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/SearchHistoryResponseFactory.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/SearchHistoryResponseFactory.java @@ -25,7 +25,7 @@ import java.util.Map; import java.util.function.Predicate; import java.util.function.UnaryOperator; import java.util.stream.Stream; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.component.SnapshotDto; import org.sonar.db.measure.MeasureDto; import org.sonar.db.metric.MetricDto; @@ -53,7 +53,7 @@ class SearchHistoryResponseFactory { .map(addPaging()) .map(addMeasures()) .map(SearchHistoryResponse.Builder::build) - .collect(Collectors.toOneElement()); + .collect(MoreCollectors.toOneElement()); } private UnaryOperator<SearchHistoryResponse.Builder> addPaging() { @@ -61,8 +61,8 @@ class SearchHistoryResponseFactory { } private UnaryOperator<SearchHistoryResponse.Builder> addMeasures() { - Map<Integer, MetricDto> metricsById = result.getMetrics().stream().collect(Collectors.uniqueIndex(MetricDto::getId)); - Map<String, SnapshotDto> analysesByUuid = result.getAnalyses().stream().collect(Collectors.uniqueIndex(SnapshotDto::getUuid)); + Map<Integer, MetricDto> metricsById = result.getMetrics().stream().collect(MoreCollectors.uniqueIndex(MetricDto::getId)); + Map<String, SnapshotDto> analysesByUuid = result.getAnalyses().stream().collect(MoreCollectors.uniqueIndex(SnapshotDto::getUuid)); Table<MetricDto, SnapshotDto, MeasureDto> measuresByMetricByAnalysis = HashBasedTable.create(result.getMetrics().size(), result.getAnalyses().size()); result.getMeasures().forEach(m -> measuresByMetricByAnalysis.put(metricsById.get(m.getMetricId()), analysesByUuid.get(m.getAnalysisUuid()), m)); diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/SearchHistoryResult.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/SearchHistoryResult.java index ef16d831b3d..22d7440bbd0 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/SearchHistoryResult.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/SearchHistoryResult.java @@ -25,7 +25,7 @@ import com.google.common.collect.Table; import java.util.ArrayList; import java.util.List; import java.util.Set; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.SnapshotDto; import org.sonar.db.measure.MeasureDto; @@ -67,7 +67,7 @@ class SearchHistoryResult { SearchHistoryResult setAnalyses(List<SnapshotDto> analyses) { this.paging = Common.Paging.newBuilder().setPageIndex(request.getPage()).setPageSize(request.getPageSize()).setTotal(analyses.size()).build(); - this.analyses = analyses.stream().skip(offset(request.getPage(), request.getPageSize())).limit(request.getPageSize()).collect(Collectors.toList()); + this.analyses = analyses.stream().skip(offset(request.getPage(), request.getPageSize())).limit(request.getPageSize()).collect(MoreCollectors.toList()); return this; } @@ -86,11 +86,11 @@ class SearchHistoryResult { } SearchHistoryResult setMeasures(List<MeasureDto> measures) { - Set<String> analysisUuids = analyses.stream().map(SnapshotDto::getUuid).collect(Collectors.toHashSet()); + Set<String> analysisUuids = analyses.stream().map(SnapshotDto::getUuid).collect(MoreCollectors.toHashSet()); ImmutableList.Builder<MeasureDto> measuresBuilder = ImmutableList.builder(); List<MeasureDto> filteredMeasures = measures.stream() .filter(measure -> analysisUuids.contains(measure.getAnalysisUuid())) - .collect(Collectors.toArrayList()); + .collect(MoreCollectors.toArrayList()); measuresBuilder.addAll(filteredMeasures); measuresBuilder.addAll(computeBestValues(filteredMeasures)); diff --git a/server/sonar-server/src/main/java/org/sonar/server/notification/NotificationUpdater.java b/server/sonar-server/src/main/java/org/sonar/server/notification/NotificationUpdater.java index 377c54a37e7..3df6ce3c812 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/notification/NotificationUpdater.java +++ b/server/sonar-server/src/main/java/org/sonar/server/notification/NotificationUpdater.java @@ -22,7 +22,7 @@ package org.sonar.server.notification; import java.util.List; import java.util.function.Predicate; import javax.annotation.Nullable; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -64,7 +64,7 @@ public class NotificationUpdater { .build(), dbSession).stream() .filter(notificationScope(project)) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); checkArgument(existingNotification.isEmpty() || !PROP_NOTIFICATION_VALUE.equals(existingNotification.get(0).getValue()), "Notification already added"); @@ -95,7 +95,7 @@ public class NotificationUpdater { .build(), dbSession).stream() .filter(notificationScope(project)) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); checkArgument(!existingNotification.isEmpty() && PROP_NOTIFICATION_VALUE.equals(existingNotification.get(0).getValue()), "Notification doesn't exist"); dbClient.propertiesDao().delete(dbSession, new PropertyDto() diff --git a/server/sonar-server/src/main/java/org/sonar/server/notification/ws/AddAction.java b/server/sonar-server/src/main/java/org/sonar/server/notification/ws/AddAction.java index a542627c587..921387991bd 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/notification/ws/AddAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/notification/ws/AddAction.java @@ -44,7 +44,7 @@ import org.sonarqube.ws.client.notification.AddRequest; import static java.util.Optional.empty; import static org.sonar.core.util.Protobuf.setNullable; -import static org.sonar.core.util.stream.Collectors.toList; +import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.server.notification.NotificationDispatcherMetadata.GLOBAL_NOTIFICATION; import static org.sonar.server.notification.NotificationDispatcherMetadata.PER_PROJECT_NOTIFICATION; import static org.sonar.server.ws.WsUtils.checkRequest; diff --git a/server/sonar-server/src/main/java/org/sonar/server/notification/ws/ListAction.java b/server/sonar-server/src/main/java/org/sonar/server/notification/ws/ListAction.java index 380718b1dcd..d7d0a8bbd45 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/notification/ws/ListAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/notification/ws/ListAction.java @@ -36,7 +36,7 @@ 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.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -53,7 +53,7 @@ import static java.util.Comparator.comparing; import static java.util.Comparator.naturalOrder; import static java.util.Comparator.nullsFirst; import static org.sonar.core.util.Protobuf.setNullable; -import static org.sonar.core.util.stream.Collectors.toOneElement; +import static org.sonar.core.util.stream.MoreCollectors.toOneElement; import static org.sonar.server.notification.NotificationDispatcherMetadata.GLOBAL_NOTIFICATION; import static org.sonar.server.notification.NotificationDispatcherMetadata.PER_PROJECT_NOTIFICATION; import static org.sonar.server.ws.WsUtils.writeProtobuf; @@ -71,9 +71,9 @@ public class ListAction implements NotificationsWsAction { public ListAction(NotificationCenter notificationCenter, DbClient dbClient, UserSession userSession) { this.dbClient = dbClient; this.userSession = userSession; - this.globalDispatchers = notificationCenter.getDispatcherKeysForProperty(GLOBAL_NOTIFICATION, "true").stream().sorted().collect(Collectors.toList()); - this.perProjectDispatchers = notificationCenter.getDispatcherKeysForProperty(PER_PROJECT_NOTIFICATION, "true").stream().sorted().collect(Collectors.toList()); - this.channels = notificationCenter.getChannels().stream().map(NotificationChannel::getKey).sorted().collect(Collectors.toList()); + this.globalDispatchers = notificationCenter.getDispatcherKeysForProperty(GLOBAL_NOTIFICATION, "true").stream().sorted().collect(MoreCollectors.toList()); + this.perProjectDispatchers = notificationCenter.getDispatcherKeysForProperty(PER_PROJECT_NOTIFICATION, "true").stream().sorted().collect(MoreCollectors.toList()); + this.channels = notificationCenter.getChannels().stream().map(NotificationChannel::getKey).sorted().collect(MoreCollectors.toList()); } @Override @@ -154,20 +154,20 @@ public class ListAction implements NotificationsWsAction { Set<Long> componentIds = properties.stream() .map(PropertyDto::getResourceId) .filter(Objects::nonNull) - .collect(Collectors.toSet(properties.size())); + .collect(MoreCollectors.toSet(properties.size())); return dbClient.componentDao().selectByIds(dbSession, componentIds) .stream() .filter(c -> authorizedComponentUuids.contains(c.uuid())) - .collect(Collectors.uniqueIndex(ComponentDto::getId)); + .collect(MoreCollectors.uniqueIndex(ComponentDto::getId)); } private Map<String, OrganizationDto> getOrganizations(DbSession dbSession, Collection<ComponentDto> values) { Set<String> organizationUuids = values.stream() .map(ComponentDto::getOrganizationUuid) - .collect(Collectors.toSet()); + .collect(MoreCollectors.toSet()); return dbClient.organizationDao().selectByUuids(dbSession, organizationUuids) .stream() - .collect(Collectors.uniqueIndex(OrganizationDto::getUuid)); + .collect(MoreCollectors.uniqueIndex(OrganizationDto::getUuid)); } private static Function<PropertyDto, Notification> toWsNotification(Notification.Builder notification, diff --git a/server/sonar-server/src/main/java/org/sonar/server/organization/ws/DeleteAction.java b/server/sonar-server/src/main/java/org/sonar/server/organization/ws/DeleteAction.java index 6837001fa34..46d45212ae3 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/organization/ws/DeleteAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/organization/ws/DeleteAction.java @@ -23,7 +23,7 @@ import java.util.List; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -137,7 +137,7 @@ public class DeleteAction implements OrganizationsWsAction { List<QualityProfileDto> profiles = dbClient.qualityProfileDao().selectAll(dbSession, organization); List<String> profileKeys = profiles.stream() .map(QualityProfileDto::getKey) - .collect(Collectors.toArrayList(profiles.size())); + .collect(MoreCollectors.toArrayList(profiles.size())); qProfileFactory.deleteByKeys(dbSession, profileKeys); dbSession.commit(); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/organization/ws/SearchMembersAction.java b/server/sonar-server/src/main/java/org/sonar/server/organization/ws/SearchMembersAction.java index 1dffd2a3e11..88ff3780daa 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/organization/ws/SearchMembersAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/organization/ws/SearchMembersAction.java @@ -33,7 +33,7 @@ import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.server.ws.WebService.SelectionMode; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.organization.OrganizationDto; @@ -103,11 +103,11 @@ public class SearchMembersAction implements OrganizationsWsAction { SearchOptions searchOptions = buildSearchOptions(request); SearchResult<UserDoc> searchResults = userIndex.search(userQuery.build(), searchOptions); - List<String> orderedLogins = searchResults.getDocs().stream().map(UserDoc::login).collect(Collectors.toList()); + List<String> orderedLogins = searchResults.getDocs().stream().map(UserDoc::login).collect(MoreCollectors.toList()); List<UserDto> users = dbClient.userDao().selectByLogins(dbSession, orderedLogins).stream() .sorted(Ordering.explicit(orderedLogins).onResultOf(UserDto::getLogin)) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); Multiset<String> groupCountByLogin = null; if (userSession.hasPermission(OrganizationPermission.ADMINISTER, organization)) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/PermissionTemplateService.java b/server/sonar-server/src/main/java/org/sonar/server/permission/PermissionTemplateService.java index 9a9f2b1d2cf..858338adc78 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/PermissionTemplateService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/PermissionTemplateService.java @@ -31,7 +31,7 @@ import org.apache.commons.lang.StringUtils; import org.sonar.api.resources.Qualifiers; import org.sonar.api.server.ServerSide; import org.sonar.core.component.ComponentKeys; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -103,7 +103,7 @@ public class PermissionTemplateService { copyPermissions(dbSession, template, project, null); } dbSession.commit(); - indexProjectPermissions(dbSession, projects.stream().map(ComponentDto::uuid).collect(Collectors.toList())); + indexProjectPermissions(dbSession, projects.stream().map(ComponentDto::uuid).collect(MoreCollectors.toList())); } /** diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/index/PermissionIndexer.java b/server/sonar-server/src/main/java/org/sonar/server/permission/index/PermissionIndexer.java index 9e44dfff342..9ee21a3ef2b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/index/PermissionIndexer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/index/PermissionIndexer.java @@ -29,7 +29,7 @@ import java.util.Set; import java.util.stream.Stream; import org.elasticsearch.action.index.IndexRequest; import org.sonar.api.utils.DateUtils; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.server.es.BulkIndexer; @@ -41,7 +41,7 @@ import org.sonar.server.es.StartupIndexer; import org.sonar.server.permission.index.PermissionIndexerDao.Dto; import static com.google.common.base.Preconditions.checkArgument; -import static org.sonar.core.util.stream.Collectors.toSet; +import static org.sonar.core.util.stream.MoreCollectors.toSet; /** * Manages the synchronization of indexes with authorization settings defined in database: @@ -62,7 +62,7 @@ public class PermissionIndexer implements ProjectIndexer, StartupIndexer { public PermissionIndexer(DbClient dbClient, EsClient esClient, NeedAuthorizationIndexer... needAuthorizationIndexers) { this(dbClient, esClient, Arrays.stream(needAuthorizationIndexers) .map(NeedAuthorizationIndexer::getAuthorizationScope) - .collect(Collectors.toList(needAuthorizationIndexers.length))); + .collect(MoreCollectors.toList(needAuthorizationIndexers.length))); } @VisibleForTesting diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/GroupsAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/GroupsAction.java index e1d0db778db..1f6e95b0f23 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/GroupsAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/GroupsAction.java @@ -31,7 +31,7 @@ import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.utils.Paging; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.organization.OrganizationDto; @@ -162,7 +162,7 @@ public class GroupsAction implements PermissionsWsAction { if (groups.isEmpty()) { return emptyList(); } - List<Integer> ids = groups.stream().map(GroupDto::getId).collect(Collectors.toList(groups.size())); + List<Integer> ids = groups.stream().map(GroupDto::getId).collect(MoreCollectors.toList(groups.size())); return dbClient.groupPermissionDao().selectByGroupIds(dbSession, org.getUuid(), ids, project.isPresent() ? project.get().getId() : null); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SonarQubeMonitor.java b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SonarQubeMonitor.java index 219f3f6f88e..7a864c6471f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SonarQubeMonitor.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SonarQubeMonitor.java @@ -32,7 +32,7 @@ import org.sonar.api.config.Settings; import org.sonar.api.platform.Server; import org.sonar.api.security.SecurityRealm; import org.sonar.api.server.authentication.IdentityProvider; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.process.ProcessProperties; import org.sonar.server.authentication.IdentityProviderRepository; import org.sonar.server.platform.ServerId; @@ -90,7 +90,7 @@ public class SonarQubeMonitor extends BaseMonitorMBean implements SonarQubeMonit .stream() .filter(IdentityProvider::isEnabled) .map(IdentityProvider::getName) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); } private List<String> getAllowsToSignUpEnabledIdentityProviders() { @@ -99,7 +99,7 @@ public class SonarQubeMonitor extends BaseMonitorMBean implements SonarQubeMonit .filter(IdentityProvider::isEnabled) .filter(IdentityProvider::allowsUsersToSignUp) .map(IdentityProvider::getName) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); } private boolean getForceAuthentication() { diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/web/RedirectFilter.java b/server/sonar-server/src/main/java/org/sonar/server/platform/web/RedirectFilter.java index 12220c383cd..c6d77b4da57 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/web/RedirectFilter.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/web/RedirectFilter.java @@ -32,7 +32,7 @@ import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import static java.lang.String.format; @@ -54,7 +54,7 @@ public class RedirectFilter implements Filter { Predicate<Redirect> match = redirect -> redirect.test(path); List<Redirect> redirects = REDIRECTS.stream() .filter(match) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); switch (redirects.size()) { case 0: diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/ws/LogsAction.java b/server/sonar-server/src/main/java/org/sonar/server/platform/ws/LogsAction.java index 2be3a516bc4..ade4e46d3e2 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/ws/LogsAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/ws/LogsAction.java @@ -25,7 +25,7 @@ import org.apache.commons.io.FileUtils; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.process.ProcessId; import org.sonar.server.platform.ServerLogging; import org.sonar.server.user.UserSession; @@ -58,7 +58,7 @@ public class LogsAction implements SystemWsAction { .setPossibleValues(stream(ProcessId.values()) .map(ProcessId::getKey) .sorted() - .collect(Collectors.toList(ProcessId.values().length))) + .collect(MoreCollectors.toList(ProcessId.values().length))) .setDefaultValue(ProcessId.APP.getKey()) .setSince("6.2") .setDescription("Process to get logs from"); diff --git a/server/sonar-server/src/main/java/org/sonar/server/project/ws/IndexAction.java b/server/sonar-server/src/main/java/org/sonar/server/project/ws/IndexAction.java index 9a2f3a6fc76..2a119d7a7ed 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/project/ws/IndexAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/project/ws/IndexAction.java @@ -31,7 +31,7 @@ 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.utils.text.JsonWriter; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -39,7 +39,7 @@ import org.sonar.server.user.UserSession; import static java.util.Optional.ofNullable; import static org.sonar.api.web.UserRole.USER; -import static org.sonar.core.util.stream.Collectors.uniqueIndex; +import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex; import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001; import static org.sonarqube.ws.client.project.ProjectsWsParameters.ACTION_INDEX; @@ -139,13 +139,13 @@ public class IndexAction implements ProjectsWsAction { // Meanwhile root is explicitly handled. return components; } - Set<String> projectUuids = components.stream().map(ComponentDto::projectUuid).collect(Collectors.toSet()); + Set<String> projectUuids = components.stream().map(ComponentDto::projectUuid).collect(MoreCollectors.toSet()); List<ComponentDto> projects = dbClient.componentDao().selectByUuids(dbSession, projectUuids); Map<String, Long> projectIdsByUuids = projects.stream().collect(uniqueIndex(ComponentDto::uuid, ComponentDto::getId)); Collection<Long> authorizedProjectIds = dbClient.authorizationDao().keepAuthorizedProjectIds(dbSession, projectIdsByUuids.values(), userSession.getUserId(), USER); return components.stream() .filter(component -> authorizedProjectIds.contains(projectIdsByUuids.get(component.projectUuid()))) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); } private static void addProject(JsonWriter json, ComponentDto project) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/SearchAction.java index ea9b7ec5537..5505546966d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/SearchAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/SearchAction.java @@ -31,7 +31,7 @@ import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.web.UserRole; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -45,7 +45,7 @@ import org.sonarqube.ws.client.projectanalysis.EventCategory; import org.sonarqube.ws.client.projectanalysis.SearchRequest; import static com.google.common.base.Preconditions.checkArgument; -import static org.sonar.core.util.stream.Collectors.toOneElement; +import static org.sonar.core.util.stream.MoreCollectors.toOneElement; import static org.sonar.db.component.SnapshotQuery.SORT_FIELD.BY_DATE; import static org.sonar.db.component.SnapshotQuery.SORT_ORDER.DESC; import static org.sonar.server.ws.WsUtils.writeProtobuf; @@ -133,7 +133,7 @@ public class SearchAction implements ProjectAnalysesWsAction { private Consumer<SearchResults.Builder> addEvents() { return data -> { - List<String> analyses = data.getAnalyses().stream().map(SnapshotDto::getUuid).collect(Collectors.toList()); + List<String> analyses = data.getAnalyses().stream().map(SnapshotDto::getUuid).collect(MoreCollectors.toList()); data.setEvents(dbClient.eventDao().selectByAnalysisUuids(data.getDbSession(), analyses)); }; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/SearchResponseBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/SearchResponseBuilder.java index fe168228ee3..07152e97f19 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/SearchResponseBuilder.java +++ b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/SearchResponseBuilder.java @@ -22,7 +22,7 @@ package org.sonar.server.projectanalysis.ws; import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Stream; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.component.SnapshotDto; import org.sonar.db.event.EventDto; import org.sonarqube.ws.ProjectAnalyses.Analysis; @@ -47,7 +47,7 @@ class SearchResponseBuilder { .peek(addAnalyses(searchResults)) .peek(addPagination(searchResults)) .map(SearchResponse.Builder::build) - .collect(Collectors.toOneElement()); + .collect(MoreCollectors.toOneElement()); } private Consumer<SearchResponse.Builder> addAnalyses(SearchResults searchResults) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/SearchResults.java b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/SearchResults.java index 039ec2ca5c4..8e725ccc6ae 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/SearchResults.java +++ b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/SearchResults.java @@ -24,7 +24,7 @@ import java.util.List; import java.util.function.Predicate; import java.util.stream.Stream; import org.sonar.api.utils.Paging; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.SnapshotDto; @@ -48,7 +48,7 @@ class SearchResults { } private ListMultimap<String, EventDto> buildEvents(List<EventDto> events) { - return events.stream().collect(Collectors.index(EventDto::getAnalysisUuid)); + return events.stream().collect(MoreCollectors.index(EventDto::getAnalysisUuid)); } static Builder builder(DbSession dbSession, SearchRequest request) { @@ -82,7 +82,7 @@ class SearchResults { .limit(request.getPageSize()); } - this.analyses = stream.collect(Collectors.toList()); + this.analyses = stream.collect(MoreCollectors.toList()); this.countAnalyses = analyses.size(); return this; } @@ -110,14 +110,14 @@ class SearchResults { private void filterByCategory() { ListMultimap<String, String> eventCategoriesByAnalysisUuid = events.stream() - .collect(Collectors.index(EventDto::getAnalysisUuid, EventDto::getCategory)); + .collect(MoreCollectors.index(EventDto::getAnalysisUuid, EventDto::getCategory)); Predicate<SnapshotDto> byCategory = a -> eventCategoriesByAnalysisUuid.get(a.getUuid()).contains(request.getCategory().getLabel()); this.countAnalyses = (int) analyses.stream().filter(byCategory).count(); this.analyses = analyses.stream() .filter(byCategory) .skip(Paging.offset(request.getPage(), request.getPageSize())) .limit(request.getPageSize()) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); } SearchResults build() { diff --git a/server/sonar-server/src/main/java/org/sonar/server/projecttag/ws/SetAction.java b/server/sonar-server/src/main/java/org/sonar/server/projecttag/ws/SetAction.java index 039ee751d14..8fdffb9b20b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/projecttag/ws/SetAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/projecttag/ws/SetAction.java @@ -27,7 +27,7 @@ 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.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -89,7 +89,7 @@ public class SetAction implements ProjectTagsWsAction { .map(t -> t.toLowerCase(Locale.ENGLISH)) .map(SetAction::checkTag) .distinct() - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); try (DbSession dbSession = dbClient.openSession(false)) { ComponentDto project = componentFinder.getByKey(dbSession, projectKey); diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/QgateProjectFinder.java b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/QgateProjectFinder.java index fa5decc0225..4d9e79bd748 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/QgateProjectFinder.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/QgateProjectFinder.java @@ -24,7 +24,7 @@ import java.util.List; import org.sonar.api.server.ServerSide; import org.sonar.api.utils.Paging; import org.sonar.api.web.UserRole; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.qualitygate.ProjectQgateAssociation; @@ -70,11 +70,11 @@ public class QgateProjectFinder { } private static List<ProjectQgateAssociationDto> getPaginatedProjects(List<ProjectQgateAssociationDto> projects, Paging paging) { - return projects.stream().skip(paging.offset()).limit(paging.pageSize()).collect(Collectors.toList()); + return projects.stream().skip(paging.offset()).limit(paging.pageSize()).collect(MoreCollectors.toList()); } private static List<ProjectQgateAssociation> toProjectAssociations(List<ProjectQgateAssociationDto> dtos) { - return dtos.stream().map(ProjectQgateAssociationDto::toQgateAssociation).collect(Collectors.toList()); + return dtos.stream().map(ProjectQgateAssociationDto::toQgateAssociation).collect(MoreCollectors.toList()); } private List<ProjectQgateAssociationDto> keepAuthorizedProjects(DbSession dbSession, List<ProjectQgateAssociationDto> projects) { @@ -84,9 +84,9 @@ public class QgateProjectFinder { // Meanwhile root is explicitly handled. return projects; } - List<Long> projectIds = projects.stream().map(ProjectQgateAssociationDto::getId).collect(Collectors.toList()); + List<Long> projectIds = projects.stream().map(ProjectQgateAssociationDto::getId).collect(MoreCollectors.toList()); Collection<Long> authorizedProjectIds = dbClient.authorizationDao().keepAuthorizedProjectIds(dbSession, projectIds, userSession.getUserId(), UserRole.USER); - return projects.stream().filter(project -> authorizedProjectIds.contains(project.getId())).collect(Collectors.toList()); + return projects.stream().filter(project -> authorizedProjectIds.contains(project.getId())).collect(MoreCollectors.toList()); } public static class Association { diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ValidRatingMetrics.java b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ValidRatingMetrics.java index feab37f24b5..13d31d912d2 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ValidRatingMetrics.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ValidRatingMetrics.java @@ -23,7 +23,7 @@ import java.util.Set; import org.sonar.api.measures.CoreMetrics; import static org.sonar.api.measures.Metric.ValueType.RATING; -import static org.sonar.core.util.stream.Collectors.toSet; +import static org.sonar.core.util.stream.MoreCollectors.toSet; public class ValidRatingMetrics { diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/CachingRuleActivatorContextFactory.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/CachingRuleActivatorContextFactory.java index 5bd0730b6e6..befd97398bb 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/CachingRuleActivatorContextFactory.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/CachingRuleActivatorContextFactory.java @@ -27,7 +27,7 @@ import java.util.Optional; import java.util.concurrent.ExecutionException; import org.picocontainer.Startable; import org.sonar.api.rule.RuleKey; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.qualityprofile.ActiveRuleDto; @@ -78,6 +78,6 @@ public class CachingRuleActivatorContextFactory extends RuleActivatorContextFact private Map<RuleKey, ActiveRuleDto> loadActiveRulesOfQualityProfile(DbSession session, String profileKey) { return dbClient.activeRuleDao().selectByProfileKey(session, profileKey).stream() - .collect(Collectors.uniqueIndex(dto -> dto.getKey().ruleKey())); + .collect(MoreCollectors.uniqueIndex(dto -> dto.getKey().ruleKey())); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/DefinedQProfileRepositoryImpl.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/DefinedQProfileRepositoryImpl.java index e89d2fd1e0d..34a354f2502 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/DefinedQProfileRepositoryImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/DefinedQProfileRepositoryImpl.java @@ -40,7 +40,7 @@ import org.sonar.api.utils.ValidationMessages; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; import org.sonar.api.utils.log.Profiler; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; @@ -123,12 +123,12 @@ public class DefinedQProfileRepositoryImpl implements DefinedQProfileRepository Map<String, List<DefinedQProfile.Builder>> buildersByLanguage = Multimaps.asMap(rulesProfilesByLanguage) .entrySet() .stream() - .collect(Collectors.uniqueIndex(Map.Entry::getKey, DefinedQProfileRepositoryImpl::toQualityProfileBuilders)); + .collect(MoreCollectors.uniqueIndex(Map.Entry::getKey, DefinedQProfileRepositoryImpl::toQualityProfileBuilders)); return buildersByLanguage .entrySet() .stream() .filter(DefinedQProfileRepositoryImpl::ensureAtMostOneDeclaredDefault) - .collect(Collectors.uniqueIndex(Map.Entry::getKey, entry -> toQualityProfiles(entry.getValue()), buildersByLanguage.size())); + .collect(MoreCollectors.uniqueIndex(Map.Entry::getKey, entry -> toQualityProfiles(entry.getValue()), buildersByLanguage.size())); } /** @@ -162,7 +162,7 @@ public class DefinedQProfileRepositoryImpl implements DefinedQProfileRepository Set<String> declaredDefaultProfileNames = entry.getValue().stream() .filter(DefinedQProfile.Builder::isDeclaredDefault) .map(DefinedQProfile.Builder::getName) - .collect(Collectors.toSet()); + .collect(MoreCollectors.toSet()); checkState(declaredDefaultProfileNames.size() <= 1, "Several Quality profiles are flagged as default for the language %s: %s", entry.getKey(), declaredDefaultProfileNames); return true; } @@ -195,6 +195,6 @@ public class DefinedQProfileRepositoryImpl implements DefinedQProfileRepository MessageDigest md5Digest = DigestUtils.getMd5Digest(); return builders.stream() .map(builder -> builder.build(md5Digest)) - .collect(Collectors.toList(builders.size())); + .collect(MoreCollectors.toList(builders.size())); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QPMeasureData.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QPMeasureData.java index 8a65e4671d2..b01609fc17b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QPMeasureData.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QPMeasureData.java @@ -33,7 +33,7 @@ import org.sonar.api.utils.text.JsonWriter; import org.sonar.core.util.UtcDateUtils; import static java.util.function.Function.identity; -import static org.sonar.core.util.stream.Collectors.uniqueIndex; +import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex; /** * Represents the array of JSON objects stored in the value of the diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexer.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexer.java index 6c07ddbe83e..7b54ecb5833 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexer.java @@ -26,7 +26,7 @@ import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.search.SearchRequestBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.sonar.api.utils.System2; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.qualityprofile.ActiveRuleKey; @@ -88,7 +88,7 @@ public class ActiveRuleIndexer extends BaseIndexer { deleteKeys(changes.stream() .filter(c -> c.getType().equals(ActiveRuleChange.Type.DEACTIVATED)) .map(ActiveRuleChange::getKey) - .collect(Collectors.toList(changes.size()))); + .collect(MoreCollectors.toList(changes.size()))); index(); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogLoader.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogLoader.java index 301e803db66..2a0cf91dfb6 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogLoader.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogLoader.java @@ -29,7 +29,7 @@ import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.sonar.api.rule.RuleKey; import org.sonar.api.server.ServerSide; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.qualityprofile.QProfileChangeDto; @@ -55,7 +55,7 @@ public class ChangelogLoader { List<QProfileChangeDto> dtos = dbClient.qProfileChangeDao().selectByQuery(dbSession, query); List<Change> changes = dtos.stream() .map(Change::from) - .collect(Collectors.toList(dtos.size())); + .collect(MoreCollectors.toList(dtos.size())); completeUserAndRuleNames(dbSession, changes); int total = dbClient.qProfileChangeDao().countForProfileKey(dbSession, query.getProfileKey()); @@ -63,13 +63,13 @@ public class ChangelogLoader { } private void completeUserAndRuleNames(DbSession dbSession, List<Change> changes) { - Set<String> logins = changes.stream().filter(c -> c.userLogin != null).map(c -> c.userLogin).collect(Collectors.toSet()); + Set<String> logins = changes.stream().filter(c -> c.userLogin != null).map(c -> c.userLogin).collect(MoreCollectors.toSet()); Map<String, String> userNamesByLogins = dbClient.userDao() .selectByLogins(dbSession, logins) .stream() .collect(java.util.stream.Collectors.toMap(UserDto::getLogin, UserDto::getName)); - Set<RuleKey> ruleKeys = changes.stream().filter(c -> c.ruleKey != null).map(c -> c.ruleKey).collect(Collectors.toSet()); + Set<RuleKey> ruleKeys = changes.stream().filter(c -> c.ruleKey != null).map(c -> c.ruleKey).collect(MoreCollectors.toSet()); Map<RuleKey, String> ruleNamesByKeys = dbClient.ruleDao() .selectDefinitionByKeys(dbSession, Lists.newArrayList(ruleKeys)) .stream() diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/DeleteAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/DeleteAction.java index bd1e52f502b..63fdcda63c9 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/DeleteAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/DeleteAction.java @@ -26,7 +26,7 @@ import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService.NewAction; import org.sonar.api.server.ws.WebService.NewController; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.qualityprofile.QualityProfileDto; @@ -100,6 +100,6 @@ public class DeleteAction implements QProfileWsAction { private static List<String> toKeys(QualityProfileDto profile, List<QualityProfileDto> descendants) { return Stream.concat(Stream.of(profile), descendants.stream()) .map(QualityProfileDto::getKee) - .collect(Collectors.toList(descendants.size() + 1)); + .collect(MoreCollectors.toList(descendants.size() + 1)); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ExportAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ExportAction.java index cb6435d1a8f..0867d67248a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ExportAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ExportAction.java @@ -34,7 +34,7 @@ import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.Response.Stream; import org.sonar.api.server.ws.WebService; import org.sonar.api.server.ws.WebService.NewAction; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.organization.OrganizationDto; @@ -90,7 +90,7 @@ public class ExportAction implements QProfileWsAction { .map(language -> exporters.exportersForLanguage(language.getKey())) .flatMap(Collection::stream) .map(ProfileExporter::getKey) - .collect(Collectors.toSet()); + .collect(MoreCollectors.toSet()); if (!exporterKeys.isEmpty()) { action.createParam(PARAM_FORMAT) .setDescription("Output format. If left empty, the same format as api/qualityprofiles/backup is used. " + diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileReference.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileReference.java index 028f3caefab..f13794632bc 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileReference.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileReference.java @@ -27,7 +27,7 @@ import org.sonar.api.resources.Languages; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.WebService; import org.sonar.core.util.Uuids; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; @@ -183,6 +183,6 @@ public class QProfileReference { .setExampleValue("Sonar way"); action.createParam(PARAM_LANGUAGE) .setDescription("A quality profile language. If this parameter is set, profileKey must not be set and profileName must be set to disambiguate.") - .setPossibleValues(Arrays.stream(languages.all()).map(Language::getKey).collect(Collectors.toSet())); + .setPossibleValues(Arrays.stream(languages.all()).map(Language::getKey).collect(MoreCollectors.toSet())); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java index 272152e92b5..c7ce5e98da0 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java @@ -42,7 +42,7 @@ import org.sonar.api.utils.System2; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; import org.sonar.api.utils.log.Profiler; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.organization.OrganizationDto; @@ -113,7 +113,7 @@ public class RegisterRules implements Startable { session.commit(); persistRepositories(session, context.repositories()); - ruleIndexer.delete(removedRules.stream().map(RuleDefinitionDto::getKey).collect(Collectors.toList(removedRules.size()))); + ruleIndexer.delete(removedRules.stream().map(RuleDefinitionDto::getKey).collect(MoreCollectors.toList(removedRules.size()))); ruleIndexer.index(getDefaultOrganization(), keysToIndex); activeRuleIndexer.index(changes); profiler.stopDebug(); @@ -132,7 +132,7 @@ public class RegisterRules implements Startable { List<RuleRepositoryDto> dtos = repositories .stream() .map(r -> new RuleRepositoryDto(r.key(), r.language(), r.name())) - .collect(Collectors.toList(repositories.size())); + .collect(MoreCollectors.toList(repositories.size())); dbClient.ruleRepositoryDao().insert(dbSession, dtos); dbSession.commit(); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ActiveRuleCompleter.java b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ActiveRuleCompleter.java index 77f329e5f8f..8161c9b2c99 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ActiveRuleCompleter.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ActiveRuleCompleter.java @@ -36,7 +36,7 @@ import org.sonar.api.server.ServerSide; import org.sonar.api.utils.DateUtils; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.qualityprofile.ActiveRuleDto; @@ -86,7 +86,7 @@ public class ActiveRuleCompleter { if (profileKey != null) { // Load details of active rules on the selected profile List<ActiveRuleDto> activeRuleDtos = dbClient.activeRuleDao().selectByProfileKey(dbSession, profileKey); - Map<RuleKey, ActiveRuleDto> activeRuleByRuleKey = activeRuleDtos.stream().collect(Collectors.uniqueIndex(d -> d.getKey().ruleKey())); + Map<RuleKey, ActiveRuleDto> activeRuleByRuleKey = activeRuleDtos.stream().collect(MoreCollectors.uniqueIndex(d -> d.getKey().ruleKey())); ListMultimap<ActiveRuleKey, ActiveRuleParamDto> activeRuleParamsByActiveRuleKey = activeRuleDtosToActiveRuleParamDtos(dbSession, activeRuleDtos); for (RuleDto rule : rules) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/RepositoriesAction.java b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/RepositoriesAction.java index b9cf2a6087d..1d3f0c7f319 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/RepositoriesAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/RepositoriesAction.java @@ -29,7 +29,7 @@ import org.sonar.api.server.ws.WebService; import org.sonar.api.server.ws.WebService.NewAction; import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.utils.text.JsonWriter; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.rule.RuleRepositoryDto; @@ -88,7 +88,7 @@ public class RepositoriesAction implements RulesWsAction { return selectFromDb(languageKey).stream() .filter(r -> pattern.matcher(r.getKey()).matches() || pattern.matcher(r.getName()).matches()) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); } private Collection<RuleRepositoryDto> selectFromDb(@Nullable String language) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/SearchAction.java index 95be46d533c..a1614ff80de 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/SearchAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/SearchAction.java @@ -43,7 +43,7 @@ import org.sonar.api.rules.RuleType; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.rule.RuleDefinitionDto; @@ -348,11 +348,11 @@ public class SearchAction implements RulesWsAction { rules.add(rule); } } - List<Integer> ruleIds = rules.stream().map(RuleDto::getId).collect(Collectors.toList()); + List<Integer> ruleIds = rules.stream().map(RuleDto::getId).collect(MoreCollectors.toList()); List<Integer> templateRuleIds = rules.stream() .map(RuleDto::getTemplateId) .filter(Objects::nonNull) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); List<RuleDefinitionDto> templateRules = dbClient.ruleDao().selectDefinitionByIds(dbSession, templateRuleIds); List<RuleParamDto> ruleParamDtos = dbClient.ruleDao().selectRuleParamsByRuleIds(dbSession, ruleIds); return new SearchResult() diff --git a/server/sonar-server/src/main/java/org/sonar/server/serverid/ws/ShowAction.java b/server/sonar-server/src/main/java/org/sonar/server/serverid/ws/ShowAction.java index 97297d7ff7d..cafa7da131a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/serverid/ws/ShowAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/serverid/ws/ShowAction.java @@ -30,7 +30,7 @@ import javax.annotation.Nullable; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.property.PropertyDto; @@ -74,7 +74,7 @@ public class ShowAction implements ServerIdWsAction { userSession.checkIsSystemAdministrator(); try (DbSession dbSession = dbClient.openSession(true)) { Map<String, PropertyDto> properties = dbClient.propertiesDao().selectGlobalPropertiesByKeys(dbSession, SETTINGS_KEYS).stream() - .collect(Collectors.uniqueIndex(PropertyDto::getKey, Function.identity())); + .collect(MoreCollectors.uniqueIndex(PropertyDto::getKey, Function.identity())); writeProtobuf(doHandle(properties), request, response); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/setting/ws/ResetAction.java b/server/sonar-server/src/main/java/org/sonar/server/setting/ws/ResetAction.java index 060eccd8333..726c856c1f1 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/setting/ws/ResetAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/setting/ws/ResetAction.java @@ -29,7 +29,7 @@ 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.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -115,7 +115,7 @@ public class ResetAction implements SettingsWsAction { PropertyDefinition definition = definitions.get(key); return definition != null ? definition.key() : key; }) - .collect(Collectors.toSet())); + .collect(MoreCollectors.toSet())); } private static ResetRequest toWsRequest(Request request) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/source/SourceService.java b/server/sonar-server/src/main/java/org/sonar/server/source/SourceService.java index 99d02ccb612..3b2e6c2ee04 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/source/SourceService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/source/SourceService.java @@ -21,7 +21,7 @@ package org.sonar.server.source; import java.util.Optional; import java.util.function.Function; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.protobuf.DbFileSources; @@ -71,7 +71,7 @@ public class SourceService { .filter(line -> line.hasLine() && line.getLine() >= from) .limit((toInclusive - from) + 1L) .map(function) - .collect(Collectors.toList())); + .collect(MoreCollectors.toList())); } private static void verifyLine(int line) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/ui/PageRepository.java b/server/sonar-server/src/main/java/org/sonar/server/ui/PageRepository.java index d09edaa664e..516849eb8aa 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/ui/PageRepository.java +++ b/server/sonar-server/src/main/java/org/sonar/server/ui/PageRepository.java @@ -34,7 +34,7 @@ import org.sonar.api.web.page.Page.Qualifier; import org.sonar.api.web.page.Page.Scope; import org.sonar.api.web.page.PageDefinition; import org.sonar.core.platform.PluginRepository; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import static com.google.common.base.Preconditions.checkState; import static java.util.Collections.emptyList; @@ -78,7 +78,7 @@ public class PageRepository implements Startable { .peek(checkWellFormed()) .peek(checkPluginExists()) .sorted(comparing(Page::getKey)) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); } @Override @@ -100,7 +100,7 @@ public class PageRepository implements Startable { .filter(p -> p.getScope().equals(scope)) .filter(p -> p.isAdmin() == isAdmin) .filter(p -> GLOBAL.equals(p.getScope()) || p.getComponentQualifiers().contains(qualifier)) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); } @VisibleForTesting diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/ServerUserSession.java b/server/sonar-server/src/main/java/org/sonar/server/user/ServerUserSession.java index 478dca4eed3..48bff78747f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/user/ServerUserSession.java +++ b/server/sonar-server/src/main/java/org/sonar/server/user/ServerUserSession.java @@ -29,7 +29,7 @@ import java.util.Optional; import java.util.Set; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -126,7 +126,7 @@ public class ServerUserSession extends AbstractUserSession { } return permissionKeys.stream() .map(OrganizationPermission::fromKey) - .collect(Collectors.toSet(permissionKeys.size())); + .collect(MoreCollectors.toSet(permissionKeys.size())); } @Override diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/UserUpdater.java b/server/sonar-server/src/main/java/org/sonar/server/user/UserUpdater.java index 9c253a275c2..16bbacf758c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/user/UserUpdater.java +++ b/server/sonar-server/src/main/java/org/sonar/server/user/UserUpdater.java @@ -35,7 +35,7 @@ import org.sonar.api.config.Settings; import org.sonar.api.platform.NewUserHandler; import org.sonar.api.server.ServerSide; import org.sonar.api.utils.System2; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.organization.OrganizationMemberDto; @@ -340,7 +340,7 @@ public class UserUpdater { private static List<String> sanitizeScmAccounts(@Nullable List<String> scmAccounts) { if (scmAccounts != null) { - return scmAccounts.stream().filter(s -> !Strings.isNullOrEmpty(s)).collect(Collectors.toList()); + return scmAccounts.stream().filter(s -> !Strings.isNullOrEmpty(s)).collect(MoreCollectors.toList()); } return Collections.emptyList(); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/SearchAction.java index 70c1b2eaa80..a3648b6c6c6 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/SearchAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/SearchAction.java @@ -30,7 +30,7 @@ import org.sonar.api.server.ws.WebService; import org.sonar.api.server.ws.WebService.NewController; import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.utils.text.JsonWriter; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.organization.OrganizationDto; @@ -96,7 +96,7 @@ public class SearchAction implements UserGroupsWsAction { int limit = dbClient.groupDao().countByQuery(dbSession, organization.getUuid(), query); List<GroupDto> groups = dbClient.groupDao().selectByQuery(dbSession, organization.getUuid(), query, options.getOffset(), pageSize); - List<Integer> groupIds = groups.stream().map(GroupDto::getId).collect(Collectors.toList(groups.size())); + List<Integer> groupIds = groups.stream().map(GroupDto::getId).collect(MoreCollectors.toList(groups.size())); Map<String, Integer> userCountByGroup = dbClient.groupMembershipDao().countUsersByGroups(dbSession, groupIds); JsonWriter json = response.newJsonWriter().beginObject(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/ws/WebServiceFilter.java b/server/sonar-server/src/main/java/org/sonar/server/ws/WebServiceFilter.java index 6a1bd19f46b..d13e62d2656 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/ws/WebServiceFilter.java +++ b/server/sonar-server/src/main/java/org/sonar/server/ws/WebServiceFilter.java @@ -30,7 +30,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.sonar.api.server.ws.WebService; import org.sonar.api.web.ServletFilter; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import static java.util.stream.Stream.concat; import static org.sonar.server.property.ws.PropertiesWs.CONTROLLER_PROPERTIES; @@ -58,7 +58,7 @@ public class WebServiceFilter extends ServletFilter { webServiceEngine.controllers().stream() .flatMap(controller -> controller.actions().stream()) .map(toPath())) - .collect(Collectors.toSet()); + .collect(MoreCollectors.toSet()); this.excludeUrls = concat(concat( Stream.of("/" + CONTROLLER_PROPERTIES + "*"), MOVED_WEB_SERVICES.stream()), @@ -66,7 +66,7 @@ public class WebServiceFilter extends ServletFilter { .flatMap(controller -> controller.actions().stream()) .filter(action -> action.handler() instanceof ServletFilterHandler) .map(toPath())) - .collect(Collectors.toSet()); + .collect(MoreCollectors.toSet()); } @Override diff --git a/server/sonar-server/src/main/java/org/sonar/server/ws/ws/ListAction.java b/server/sonar-server/src/main/java/org/sonar/server/ws/ws/ListAction.java index 7b20a861a59..47f1ad24870 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/ws/ws/ListAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/ws/ws/ListAction.java @@ -28,7 +28,7 @@ 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.utils.text.JsonWriter; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import static com.google.common.base.Preconditions.checkState; @@ -109,7 +109,7 @@ public class ListAction implements WebServicesWsAction { } private static void writeParameters(JsonWriter writer, WebService.Action action, boolean includeInternals) { - List<WebService.Param> params = action.params().stream().filter(p -> includeInternals || !p.isInternal()).collect(Collectors.toList()); + List<WebService.Param> params = action.params().stream().filter(p -> includeInternals || !p.isInternal()).collect(MoreCollectors.toList()); if (!params.isEmpty()) { // sort parameters by key Ordering<WebService.Param> ordering = Ordering.natural().onResultOf(WebService.Param::key); diff --git a/server/sonar-server/src/test/java/org/sonar/server/authentication/SsoAuthenticatorTest.java b/server/sonar-server/src/test/java/org/sonar/server/authentication/SsoAuthenticatorTest.java index 1aa98293e7a..0cb53e939f6 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/authentication/SsoAuthenticatorTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/authentication/SsoAuthenticatorTest.java @@ -35,7 +35,7 @@ import org.sonar.api.config.MapSettings; import org.sonar.api.config.Settings; import org.sonar.api.utils.System2; import org.sonar.api.utils.internal.AlwaysIncreasingSystem2; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbTester; import org.sonar.db.user.GroupDto; import org.sonar.db.user.UserDto; @@ -424,7 +424,7 @@ public class SsoAuthenticatorTest { if (expectedGroups.length == 0) { assertThat(db.users().selectGroupIdsOfUser(userDto)).isEmpty(); } else { - assertThat(db.users().selectGroupIdsOfUser(userDto)).containsOnly(stream(expectedGroups).map(GroupDto::getId).collect(Collectors.toList()).toArray(new Integer[] {})); + assertThat(db.users().selectGroupIdsOfUser(userDto)).containsOnly(stream(expectedGroups).map(GroupDto::getId).collect(MoreCollectors.toList()).toArray(new Integer[] {})); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/authentication/UserIdentityAuthenticatorTest.java b/server/sonar-server/src/test/java/org/sonar/server/authentication/UserIdentityAuthenticatorTest.java index 373b0ce035e..d36d54f66c8 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/authentication/UserIdentityAuthenticatorTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/authentication/UserIdentityAuthenticatorTest.java @@ -30,7 +30,7 @@ import org.sonar.api.config.Settings; import org.sonar.api.server.authentication.UserIdentity; import org.sonar.api.utils.System2; import org.sonar.api.utils.internal.AlwaysIncreasingSystem2; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbTester; import org.sonar.db.organization.OrganizationDto; import org.sonar.db.user.GroupDto; @@ -267,7 +267,7 @@ public class UserIdentityAuthenticatorTest { .setLogin(login) .setName("John") // No group - .setGroups(Arrays.stream(groups).collect(Collectors.toSet())) + .setGroups(Arrays.stream(groups).collect(MoreCollectors.toSet())) .build(), IDENTITY_PROVIDER, Source.sso()); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java index ca2f975809d..78bd13d7f00 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java @@ -78,7 +78,7 @@ import static org.sonar.api.server.ws.WebService.Param.PAGE; import static org.sonar.api.server.ws.WebService.Param.PAGE_SIZE; import static org.sonar.api.server.ws.WebService.Param.SORT; import static org.sonar.api.utils.DateUtils.formatDateTime; -import static org.sonar.core.util.stream.Collectors.toList; +import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.db.component.ComponentTesting.newDeveloper; import static org.sonar.db.component.ComponentTesting.newDirectory; import static org.sonar.db.component.ComponentTesting.newFileDto; diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java index 229242eeb97..e7da1c433fa 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java @@ -31,7 +31,7 @@ import org.sonar.api.rule.RuleStatus; import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.DateUtils; import org.sonar.api.web.UserRole; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -719,7 +719,7 @@ public class SearchActionMediumTest { tester.get(PermissionUpdater.class).apply(session, Arrays.stream(permissions) // TODO correctly feed default organization. Not a problem as long as issues search does not support "anyone" for each organization .map(permission -> new GroupPermissionChange(PermissionChange.Operation.ADD, permission, new ProjectId(project), GroupIdOrAnyone.forAnyone(project.getOrganizationUuid()))) - .collect(Collectors.toList())); + .collect(MoreCollectors.toList())); } private ComponentDto insertComponent(ComponentDto component) { diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/SearchHistoryActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/SearchHistoryActionTest.java index 22b9e036f59..cdf0ecd23f1 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/SearchHistoryActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/SearchHistoryActionTest.java @@ -33,7 +33,7 @@ import org.sonar.api.server.ws.WebService; import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.utils.System2; import org.sonar.api.web.UserRole; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; @@ -181,7 +181,7 @@ public class SearchHistoryActionTest { .mapToObj(i -> dbClient.snapshotDao().insert(dbSession, newAnalysis(project).setCreatedAt(i * 1_000_000_000))) .peek(a -> dbClient.measureDao().insert(dbSession, newMeasureDto(complexityMetric, project, a).setValue(101d))) .map(a -> formatDateTime(a.getCreatedAt())) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); db.commit(); wsRequest.setComponent(project.getKey()).setPage(2).setPageSize(3); @@ -200,7 +200,7 @@ public class SearchHistoryActionTest { .mapToObj(i -> dbClient.snapshotDao().insert(dbSession, newAnalysis(project).setCreatedAt(System2.INSTANCE.now() + i * 1_000_000_000L))) .peek(a -> dbClient.measureDao().insert(dbSession, newMeasureDto(complexityMetric, project, a).setValue(Double.valueOf(a.getCreatedAt())))) .map(a -> formatDateTime(a.getCreatedAt())) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); db.commit(); wsRequest.setComponent(project.getKey()).setFrom(analysisDates.get(1)).setTo(analysisDates.get(3)); diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/index/FooIndex.java b/server/sonar-server/src/test/java/org/sonar/server/permission/index/FooIndex.java index 004cc7cc965..c117cab5d32 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/index/FooIndex.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/index/FooIndex.java @@ -23,7 +23,7 @@ import java.util.Arrays; import java.util.List; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.SearchHits; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.server.es.EsClient; import static org.sonar.server.permission.index.FooIndexDefinition.FOO_INDEX; @@ -49,7 +49,7 @@ public class FooIndex { .getHits(); List<String> names = Arrays.stream(hits.hits()) .map(h -> h.getSource().get(FooIndexDefinition.FIELD_NAME).toString()) - .collect(Collectors.toList()); + .collect(MoreCollectors.toList()); return names.size() == 2 && names.contains("bar") && names.contains("baz"); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/index/PermissionIndexerDaoTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/index/PermissionIndexerDaoTest.java index b39d94c0224..6b88025dd53 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/index/PermissionIndexerDaoTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/index/PermissionIndexerDaoTest.java @@ -28,7 +28,7 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.sonar.api.utils.System2; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; @@ -121,7 +121,7 @@ public class PermissionIndexerDaoTest { Map<String, PermissionIndexerDao.Dto> dtos = underTest.selectByUuids(dbClient, dbSession, asList(project1.uuid(), project2.uuid(), view1.uuid(), view2.uuid())) .stream() - .collect(Collectors.uniqueIndex(PermissionIndexerDao.Dto::getProjectUuid, Function.identity())); + .collect(MoreCollectors.uniqueIndex(PermissionIndexerDao.Dto::getProjectUuid, Function.identity())); assertThat(dtos).hasSize(4); PermissionIndexerDao.Dto project1Authorization = dtos.get(project1.uuid()); @@ -171,7 +171,7 @@ public class PermissionIndexerDaoTest { Map<String, PermissionIndexerDao.Dto> dtos = underTest.selectByUuids(dbClient, dbSession, projects) .stream() - .collect(Collectors.uniqueIndex(PermissionIndexerDao.Dto::getProjectUuid, Function.identity())); + .collect(MoreCollectors.uniqueIndex(PermissionIndexerDao.Dto::getProjectUuid, Function.identity())); assertThat(dtos).hasSize(350); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/DefinedQProfileCreationImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/DefinedQProfileCreationImplTest.java index 7622a437294..0f449bd6f1e 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/DefinedQProfileCreationImplTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/DefinedQProfileCreationImplTest.java @@ -40,7 +40,7 @@ import org.sonar.api.rules.RuleParam; import org.sonar.api.rules.RulePriority; import org.sonar.api.utils.System2; import org.sonar.core.util.UuidFactory; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; @@ -273,7 +273,7 @@ public class DefinedQProfileCreationImplTest { rule.setParams(Arrays.stream(parameters) .filter(new EvenElementPredicate()) .map(s -> new RuleParam(rule, s, "desc of s", "type of s")) - .collect(Collectors.toList(parameters.length / 2))); + .collect(MoreCollectors.toList(parameters.length / 2))); ActiveRule res = new ActiveRule( new RulesProfile("rule_profile_name_" + id, "language_" + id), rule.setSeverity(rulePriority), diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/DefinedQProfileRepositoryRule.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/DefinedQProfileRepositoryRule.java index 83ecacb5588..65a6091a7b6 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/DefinedQProfileRepositoryRule.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/DefinedQProfileRepositoryRule.java @@ -29,10 +29,10 @@ import java.util.stream.Stream; import org.apache.commons.codec.digest.DigestUtils; import org.junit.rules.ExternalResource; import org.sonar.api.resources.Language; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import static com.google.common.base.Preconditions.checkState; -import static org.sonar.core.util.stream.Collectors.toList; +import static org.sonar.core.util.stream.MoreCollectors.toList; public class DefinedQProfileRepositoryRule extends ExternalResource implements DefinedQProfileRepository { private boolean initializeCalled = false; @@ -79,7 +79,7 @@ public class DefinedQProfileRepositoryRule extends ExternalResource implements D if (existing == null) { return ImmutableList.of(definedQProfile); } - return Stream.concat(existing.stream(), Stream.of(definedQProfile)).collect(Collectors.toList(existing.size() + 1)); + return Stream.concat(existing.stream(), Stream.of(definedQProfile)).collect(MoreCollectors.toList(existing.size() + 1)); }); return definedQProfile; } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java index 279191e3a1b..faf25a4e75b 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java @@ -34,7 +34,7 @@ import org.sonar.api.rule.RuleStatus; import org.sonar.api.rule.Severity; import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.System2; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; @@ -190,7 +190,7 @@ public class ChangeParentActionTest { RuleDto rule2 = createRule(); createActiveRule(rule1, parent1); createActiveRule(rule2, parent2); - ruleIndexer.index(organization, Stream.of(rule1, rule2).map(RuleDto::getKey).collect(Collectors.toList())); + ruleIndexer.index(organization, Stream.of(rule1, rule2).map(RuleDto::getKey).collect(MoreCollectors.toList())); activeRuleIndexer.index(); // Set parent 1 diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/RulesWsMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/RulesWsMediumTest.java index 509b8a59f93..c979889d373 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/RulesWsMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/RulesWsMediumTest.java @@ -28,7 +28,7 @@ import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.sonar.api.server.ws.WebService; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.organization.OrganizationDto; @@ -155,7 +155,7 @@ public class RulesWsMediumTest { ruleDao.insertOrUpdate(session, rule2.getMetadata().setRuleId(rule2.getId())); session.commit(); - ruleIndexer.index(defaultOrganization, Stream.of(rule, rule2).map(RuleDto::getKey).collect(Collectors.toList())); + ruleIndexer.index(defaultOrganization, Stream.of(rule, rule2).map(RuleDto::getKey).collect(MoreCollectors.toList())); tester.wsTester().newGetRequest(API_ENDPOINT, API_TAGS_METHOD).execute().assertJson(this.getClass(), "get_tags.json"); tester.wsTester().newGetRequest(API_ENDPOINT, API_TAGS_METHOD) diff --git a/sonar-core/src/main/java/org/sonar/core/metric/ScannerMetrics.java b/sonar-core/src/main/java/org/sonar/core/metric/ScannerMetrics.java index 2a67bc6bf8a..6406336c580 100644 --- a/sonar-core/src/main/java/org/sonar/core/metric/ScannerMetrics.java +++ b/sonar-core/src/main/java/org/sonar/core/metric/ScannerMetrics.java @@ -63,7 +63,7 @@ import static org.sonar.api.measures.CoreMetrics.TEST_EXECUTION_TIME; import static org.sonar.api.measures.CoreMetrics.TEST_FAILURES; import static org.sonar.api.measures.CoreMetrics.UNCOVERED_CONDITIONS; import static org.sonar.api.measures.CoreMetrics.UNCOVERED_LINES; -import static org.sonar.core.util.stream.Collectors.toSet; +import static org.sonar.core.util.stream.MoreCollectors.toSet; /** * This class is used to know the list of metrics that can be sent in the analysis report. diff --git a/sonar-core/src/main/java/org/sonar/core/util/stream/Collectors.java b/sonar-core/src/main/java/org/sonar/core/util/stream/MoreCollectors.java index ae28d03fc03..64616cf921d 100644 --- a/sonar-core/src/main/java/org/sonar/core/util/stream/Collectors.java +++ b/sonar-core/src/main/java/org/sonar/core/util/stream/MoreCollectors.java @@ -38,11 +38,11 @@ import java.util.stream.Collector; import static java.util.Objects.requireNonNull; -public final class Collectors { +public final class MoreCollectors { private static final int DEFAULT_HASHMAP_CAPACITY = 0; - private Collectors() { + private MoreCollectors() { // prevents instantiation } @@ -118,7 +118,7 @@ public final class Collectors { } /** - * Does {@code java.util.stream.Collectors.toCollection(() -> new ArrayList<>(size));} which is equivalent to + * Does {@code java.util.stream.MoreCollectors.toCollection(() -> new ArrayList<>(size));} which is equivalent to * {@link #toArrayList()} but avoiding array copies when the size of the resulting list is already known. * * <p>Note: using this method with a parallel stream will likely not have the expected memory usage benefit as all @@ -139,7 +139,7 @@ public final class Collectors { } /** - * Does {@code java.util.stream.Collectors.toCollection(() -> new HashSet<>(size));} which is equivalent to + * Does {@code java.util.stream.MoreCollectors.toCollection(() -> new HashSet<>(size));} which is equivalent to * {@link #toHashSet()} but avoiding array copies when the size of the resulting set is already known. * * <p>Note: using this method with a parallel stream will likely not have the expected memory usage benefit as all diff --git a/sonar-core/src/test/java/org/sonar/core/util/stream/CollectorsTest.java b/sonar-core/src/test/java/org/sonar/core/util/stream/MoreCollectorsTest.java index d15ae533cf6..8a1e1c01a82 100644 --- a/sonar-core/src/test/java/org/sonar/core/util/stream/CollectorsTest.java +++ b/sonar-core/src/test/java/org/sonar/core/util/stream/MoreCollectorsTest.java @@ -40,15 +40,15 @@ import org.junit.rules.ExpectedException; import static java.util.function.Function.identity; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.entry; -import static org.sonar.core.util.stream.Collectors.index; -import static org.sonar.core.util.stream.Collectors.join; -import static org.sonar.core.util.stream.Collectors.toArrayList; -import static org.sonar.core.util.stream.Collectors.toHashSet; -import static org.sonar.core.util.stream.Collectors.toList; -import static org.sonar.core.util.stream.Collectors.toSet; -import static org.sonar.core.util.stream.Collectors.uniqueIndex; - -public class CollectorsTest { +import static org.sonar.core.util.stream.MoreCollectors.index; +import static org.sonar.core.util.stream.MoreCollectors.join; +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.toList; +import static org.sonar.core.util.stream.MoreCollectors.toSet; +import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex; + +public class MoreCollectorsTest { private static final List<String> HUGE_LIST = IntStream.range(0, 2_000).mapToObj(String::valueOf).collect(java.util.stream.Collectors.toList()); private static final Set<String> HUGE_SET = new HashSet<>(HUGE_LIST); diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/source/ZeroCoverageSensor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/source/ZeroCoverageSensor.java index da5482356f4..446fbd4089b 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/source/ZeroCoverageSensor.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/source/ZeroCoverageSensor.java @@ -37,7 +37,7 @@ import org.sonar.api.batch.sensor.coverage.NewCoverage; import org.sonar.api.batch.sensor.measure.internal.DefaultMeasure; import org.sonar.api.measures.CoreMetrics; import org.sonar.api.utils.KeyValueFormat; -import org.sonar.core.util.stream.Collectors; +import org.sonar.core.util.stream.MoreCollectors; import org.sonar.scanner.scan.measure.MeasureCache; import org.sonar.scanner.sensor.coverage.CoverageExclusions; @@ -104,9 +104,9 @@ public final class ZeroCoverageSensor implements Sensor { private boolean isCoverageMeasuresAlreadyDefined(InputFile f) { Set<String> metricKeys = StreamSupport.stream(measureCache.byComponentKey(f.key()).spliterator(), false) - .map(new MeasureToMetricKey()).collect(Collectors.toSet()); + .map(new MeasureToMetricKey()).collect(MoreCollectors.toSet()); Function<Metric, String> metricToKey = new MetricToKey(); - Set<String> allCoverageMetricKeys = CoverageType.UNIT.allMetrics().stream().map(metricToKey).collect(Collectors.toSet()); + Set<String> allCoverageMetricKeys = CoverageType.UNIT.allMetrics().stream().map(metricToKey).collect(MoreCollectors.toSet()); return !Sets.intersection(metricKeys, allCoverageMetricKeys).isEmpty(); } |