aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-process/src
diff options
context:
space:
mode:
authorAntoine Vigneau <antoine.vigneau@sonarsource.com>2023-03-14 15:09:53 +0100
committersonartech <sonartech@sonarsource.com>2023-03-22 20:04:07 +0000
commit6ad827619b064069105da433ea99e7a1a66b6eb6 (patch)
tree8c69fe628b8c8991b85133afb7ff1e787b8f760b /server/sonar-process/src
parentc96fc17ae41f274d56cd329af1373a94352d74bf (diff)
downloadsonarqube-6ad827619b064069105da433ea99e7a1a66b6eb6.tar.gz
sonarqube-6ad827619b064069105da433ea99e7a1a66b6eb6.zip
SONAR-18654 Make system/info return optional values
Diffstat (limited to 'server/sonar-process/src')
-rw-r--r--server/sonar-process/src/main/java/org/sonar/process/systeminfo/SystemInfoUtils.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/server/sonar-process/src/main/java/org/sonar/process/systeminfo/SystemInfoUtils.java b/server/sonar-process/src/main/java/org/sonar/process/systeminfo/SystemInfoUtils.java
index 04474e44852..24bc246d11c 100644
--- a/server/sonar-process/src/main/java/org/sonar/process/systeminfo/SystemInfoUtils.java
+++ b/server/sonar-process/src/main/java/org/sonar/process/systeminfo/SystemInfoUtils.java
@@ -19,6 +19,7 @@
*/
package org.sonar.process.systeminfo;
+import com.google.common.base.Joiner;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -33,6 +34,8 @@ import static java.util.Arrays.stream;
public class SystemInfoUtils {
+ private static final Joiner COMMA_JOINER = Joiner.on(", ");
+
private SystemInfoUtils() {
// prevent instantiation
}
@@ -95,4 +98,10 @@ public class SystemInfoUtils {
result.addAll(alphabeticalOrderedMap.values());
return result;
}
+
+ public static void addIfNotEmpty(ProtobufSystemInfo.Section.Builder protobuf, String key, @Nullable List<String> values) {
+ if (values != null && !values.isEmpty()) {
+ setAttribute(protobuf, key, COMMA_JOINER.join(values));
+ }
+ }
}