File tree 1 file changed +16
-5
lines changed
internal-api/src/main/java/datadog/trace/api/remoteconfig
1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change 5
5
import datadog .trace .api .Config ;
6
6
import java .util .ArrayList ;
7
7
import java .util .List ;
8
- import java .util .Locale ;
8
+ import java .util .Set ;
9
+ import java .util .TreeSet ;
9
10
import java .util .concurrent .ConcurrentHashMap ;
10
11
import javax .annotation .Nullable ;
11
12
import org .slf4j .Logger ;
@@ -48,14 +49,24 @@ public void addService(final String serviceName) {
48
49
}
49
50
return ;
50
51
}
51
- if (!Config .get ().getServiceName ().equalsIgnoreCase (serviceName )) {
52
- services .put (serviceName .toLowerCase (Locale .ROOT ), serviceName );
53
- }
52
+ services .putIfAbsent (serviceName , serviceName );
54
53
}
55
54
55
+ /**
56
+ * Get the list of unique services deduplicated by case. There is no locking on the addService map
57
+ * so, the method is not thread safe.
58
+ *
59
+ * @return
60
+ */
56
61
@ Nullable
57
62
public List <String > getServices () {
58
- return services .isEmpty () ? null : new ArrayList <>(services .values ());
63
+ if (services .isEmpty ()) {
64
+ return null ;
65
+ }
66
+ final Set <String > uniqueNames = new TreeSet <>(String .CASE_INSENSITIVE_ORDER );
67
+ uniqueNames .addAll (services .keySet ());
68
+ uniqueNames .remove (Config .get ().getServiceName ());
69
+ return uniqueNames .isEmpty () ? null : new ArrayList <>(uniqueNames );
59
70
}
60
71
61
72
public void clear () {
You can’t perform that action at this time.
0 commit comments