File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
api/all/src/main/java/io/opentelemetry/api/internal Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change 88import java .util .Locale ;
99import java .util .Map ;
1010import java .util .Objects ;
11+ import java .util .Properties ;
1112import javax .annotation .Nullable ;
1213
1314/**
@@ -35,13 +36,16 @@ private ConfigUtil() {}
3536 public static String getString (String key , String defaultValue ) {
3637 String normalizedKey = normalizePropertyKey (key );
3738
39+ // Cloning in order to avoid ConcurrentModificationException
40+ // see https://github.com/open-telemetry/opentelemetry-java/issues/6732
3841 String systemProperty =
39- System .getProperties ().stringPropertyNames ().stream ()
40- .filter (propertyName -> normalizedKey .equals (normalizePropertyKey (propertyName )))
41- .map (System ::getProperty )
42- .filter (Objects ::nonNull )
43- .findFirst ()
44- .orElse (null );
42+ ((Properties ) System .getProperties ().clone ())
43+ .stringPropertyNames ().stream ()
44+ .filter (propertyName -> normalizedKey .equals (normalizePropertyKey (propertyName )))
45+ .map (System ::getProperty )
46+ .filter (Objects ::nonNull )
47+ .findFirst ()
48+ .orElse (null );
4549 if (systemProperty != null ) {
4650 return systemProperty ;
4751 }
You can’t perform that action at this time.
0 commit comments