Skip to content

Commit 7bc442f

Browse files
authored
avoid ConcurrentModificationException (#1191)
Signed-off-by: Gregor Zeitlinger <[email protected]>
1 parent 76cb93e commit 7bc442f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

prometheus-metrics-config/src/main/java/io/prometheus/metrics/config/PrometheusPropertiesLoader.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@ private static Map<Object, Object> loadProperties(Map<Object, Object> externalPr
9696
Map<Object, Object> properties = new HashMap<>();
9797
properties.putAll(loadPropertiesFromClasspath());
9898
properties.putAll(loadPropertiesFromFile()); // overriding the entries from the classpath file
99-
properties.putAll(System.getProperties()); // overriding the entries from the properties file
99+
// overriding the entries from the properties file
100+
// copy System properties to avoid ConcurrentModificationException
101+
System.getProperties().stringPropertyNames().stream()
102+
.filter(key -> key.startsWith("io.prometheus"))
103+
.forEach(key -> properties.put(key, System.getProperty(key)));
100104
properties.putAll(externalProperties); // overriding all the entries above
101105
// TODO: Add environment variables like EXEMPLARS_ENABLED.
102106
return properties;

0 commit comments

Comments
 (0)