prometheus/client_java

`ConcurrentModificationException` rarely occurs when creating `PrometheusProperties`

Closed this issue · 0 comments

ConcurrentModificationException is raised when copying System.getProperties().

properties.putAll(System.getProperties()); // overriding the entries from the properties file

System.getProperties() is a shared object so iterating seems not thread-safe.

To thread-safely access the properties, we may need to copy the properties' names first.
https://stackoverflow.com/questions/52447029/how-can-i-iterate-over-system-properties-in-a-thread-safe-manner

java.util.ConcurrentModificationException
	at java.util.Hashtable$Enumerator.next(Hashtable.java:1408)
	at java.util.HashMap.putMapEntries(HashMap.java:513)
	at java.util.HashMap.putAll(HashMap.java:786)
	at io.prometheus.metrics.config.PrometheusPropertiesLoader.loadProperties(PrometheusPropertiesLoader.java:84)
	at io.prometheus.metrics.config.PrometheusPropertiesLoader.load(PrometheusPropertiesLoader.java:32)
	at io.micrometer.prometheusmetrics.PrometheusMeterRegistry.<init>(PrometheusMeterRegistry.java:106)
	at io.micrometer.prometheusmetrics.PrometheusMeterRegistry.<init>(PrometheusMeterRegistry.java:87)
	at com.linecorp.armeria.common.prometheus.PrometheusMeterRegistries.newRegistry(PrometheusMeterRegistries.java:65)
	at com.linecorp.armeria.common.prometheus.PrometheusMeterRegistries.newRegistry(PrometheusMeterRegistries.java:56)
	at com.linecorp.armeria.common.prometheus.PrometheusMeterRegistries.newRegistry(PrometheusMeterRegistries.java:48)