File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
api/all/src/main/java/io/opentelemetry/api/internal Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 55
66package io .opentelemetry .api .internal ;
77
8+ import java .util .AbstractMap ;
9+ import java .util .HashSet ;
810import java .util .Locale ;
911import java .util .Map ;
12+ import java .util .Set ;
13+ import java .util .stream .Collectors ;
1014import javax .annotation .Nullable ;
1115
1216/**
@@ -33,10 +37,15 @@ private ConfigUtil() {}
3337 */
3438 public static String getString (String key , String defaultValue ) {
3539 String normalizedKey = normalizePropertyKey (key );
40+ Set <Map .Entry <String , String >> properties = new HashSet <>(System .getProperties ().entrySet ())
41+ .stream ().filter (entry -> entry .getKey () instanceof String && entry .getValue () instanceof String )
42+ .map (entry -> new AbstractMap .SimpleEntry <>((String ) entry .getKey (), (String ) entry .getValue ()))
43+ .collect (Collectors .<Map .Entry <String , String >>toSet ());
44+
3645 String systemProperty =
37- System . getProperties (). entrySet () .stream ()
38- .filter (entry -> normalizedKey .equals (normalizePropertyKey (entry .getKey (). toString () )))
39- .map (entry -> entry . getValue (). toString () )
46+ properties .stream ()
47+ .filter (entry -> normalizedKey .equals (normalizePropertyKey (entry .getKey ())))
48+ .map (Map . Entry :: getValue )
4049 .findFirst ()
4150 .orElse (null );
4251 if (systemProperty != null ) {
You can’t perform that action at this time.
0 commit comments