Skip to content

Commit b115c5a

Browse files
committed
Move to stringPropertyNames in order to iterate on a stable list.
1 parent ab84470 commit b115c5a

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

api/all/src/main/java/io/opentelemetry/api/internal/ConfigUtil.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
package io.opentelemetry.api.internal;
77

88
import java.util.AbstractMap;
9-
import java.util.HashSet;
109
import java.util.Locale;
1110
import java.util.Map;
1211
import java.util.Set;
@@ -38,15 +37,12 @@ private ConfigUtil() {}
3837
public static String getString(String key, String defaultValue) {
3938
String normalizedKey = normalizePropertyKey(key);
4039
Set<Map.Entry<String, String>> properties =
41-
new HashSet<>(System.getProperties().entrySet())
42-
.stream()
43-
.filter(
44-
entry -> entry.getKey() instanceof String && entry.getValue() instanceof String)
45-
.map(
46-
entry ->
47-
new AbstractMap.SimpleEntry<>(
48-
(String) entry.getKey(), (String) entry.getValue()))
49-
.collect(Collectors.<Map.Entry<String, String>>toSet());
40+
System.getProperties().stringPropertyNames().stream()
41+
.map(
42+
propertyName ->
43+
new AbstractMap.SimpleEntry<>(propertyName, System.getProperty(propertyName)))
44+
.filter(entry -> entry.getKey() != null)
45+
.collect(Collectors.<Map.Entry<String, String>>toSet());
5046

5147
String systemProperty =
5248
properties.stream()

0 commit comments

Comments
 (0)