aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-main
diff options
context:
space:
mode:
authorMatteo Mara <matteo.mara@sonarsource.com>2023-01-10 15:16:50 +0100
committersonartech <sonartech@sonarsource.com>2023-01-10 20:03:01 +0000
commit54b60b1adac5b703398163ee5edf5a621efc0d24 (patch)
tree2c4595fea6ddefca2b5f33cc9c26000ffb5750ce /server/sonar-main
parent295a87208f8c9898fbdc733a438587dc03a16877 (diff)
downloadsonarqube-54b60b1adac5b703398163ee5edf5a621efc0d24.tar.gz
sonarqube-54b60b1adac5b703398163ee5edf5a621efc0d24.zip
[NO-JIRA] Remove reported code smells about usages of toList
Diffstat (limited to 'server/sonar-main')
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/command/JvmOptions.java7
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/config/ClusterSettings.java5
2 files changed, 5 insertions, 7 deletions
diff --git a/server/sonar-main/src/main/java/org/sonar/application/command/JvmOptions.java b/server/sonar-main/src/main/java/org/sonar/application/command/JvmOptions.java
index 06030298dfe..ea0a4ded5f9 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/command/JvmOptions.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/command/JvmOptions.java
@@ -26,7 +26,6 @@ import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
-import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.sonar.process.MessageException;
@@ -68,7 +67,7 @@ public class JvmOptions<T extends JvmOptions> {
public T addFromMandatoryProperty(Props props, String propertyName) {
String value = props.nonNullValue(propertyName);
if (!value.isEmpty()) {
- List<String> jvmOptions = Arrays.stream(value.split(" (?=-)")).map(String::trim).collect(Collectors.toList());
+ List<String> jvmOptions = Arrays.stream(value.split(" (?=-)")).map(String::trim).toList();
checkOptionFormat(propertyName, jvmOptions);
checkMandatoryOptionOverwrite(propertyName, jvmOptions);
options.addAll(jvmOptions);
@@ -80,7 +79,7 @@ public class JvmOptions<T extends JvmOptions> {
private static void checkOptionFormat(String propertyName, List<String> jvmOptionsFromProperty) {
List<String> invalidOptions = jvmOptionsFromProperty.stream()
.filter(JvmOptions::isInvalidOption)
- .collect(Collectors.toList());
+ .toList();
if (!invalidOptions.isEmpty()) {
throw new MessageException(format(
"a JVM option can't be empty and must start with '-'. The following JVM options defined by property '%s' are invalid: %s",
@@ -94,7 +93,7 @@ public class JvmOptions<T extends JvmOptions> {
List<Match> matches = jvmOptionsFromProperty.stream()
.map(jvmOption -> new Match(jvmOption, mandatoryOptionFor(jvmOption)))
.filter(match -> match.getMandatoryOption() != null)
- .collect(Collectors.toList());
+ .toList();
if (!matches.isEmpty()) {
throw new MessageException(format(
"a JVM option can't overwrite mandatory JVM options. The following JVM options defined by property '%s' are invalid: %s",
diff --git a/server/sonar-main/src/main/java/org/sonar/application/config/ClusterSettings.java b/server/sonar-main/src/main/java/org/sonar/application/config/ClusterSettings.java
index adf4ae26538..5236014a1b4 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/config/ClusterSettings.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/config/ClusterSettings.java
@@ -42,7 +42,6 @@ import static java.util.Arrays.stream;
import static java.util.Collections.singleton;
import static java.util.Collections.singletonList;
import static java.util.stream.Collectors.joining;
-import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toSet;
import static org.sonar.process.ProcessProperties.Property.AUTH_JWT_SECRET;
import static org.sonar.process.ProcessProperties.Property.CLUSTER_ENABLED;
@@ -146,7 +145,7 @@ public class ClusterSettings implements Consumer<Props> {
.map(AddressAndPort::getHost)
.filter(t -> !network.toInetAddress(t).isPresent())
.sorted()
- .collect(toList());
+ .toList();
if (!invalidHosts.isEmpty()) {
throw new MessageException(format("Address in property %s is not a valid address: %s",
property.getKey(), String.join(", ", invalidHosts)));
@@ -187,7 +186,7 @@ public class ClusterSettings implements Consumer<Props> {
List<String> violations = FORBIDDEN_SEARCH_NODE_SETTINGS.stream()
.filter(setting -> props.value(setting.getKey()) != null)
.map(Property::getKey)
- .collect(toList());
+ .toList();
if (!violations.isEmpty()) {
throw new MessageException(format("Properties [%s] are not allowed when running SonarQube in cluster mode.", String.join(", ", violations)));