File tree Expand file tree Collapse file tree 1 file changed +21
-17
lines changed
communication/src/main/java/datadog/communication/ddagent Expand file tree Collapse file tree 1 file changed +21
-17
lines changed Original file line number Diff line number Diff line change @@ -140,23 +140,27 @@ public void setFeaturesDiscovery(DDAgentFeaturesDiscovery featuresDiscovery) {
140140
141141 public DDAgentFeaturesDiscovery featuresDiscovery (Config config ) {
142142 if (featuresDiscovery == null ) {
143- createRemaining (config );
144- featuresDiscovery =
145- new DDAgentFeaturesDiscovery (
146- okHttpClient ,
147- monitoring ,
148- agentUrl ,
149- config .isTraceAgentV05Enabled (),
150- config .isTracerMetricsEnabled ());
151-
152- if (paused ) {
153- // defer remote discovery until remote I/O is allowed
154- } else {
155- if (AGENT_THREAD_GROUP .equals (Thread .currentThread ().getThreadGroup ())) {
156- featuresDiscovery .discover (); // safe to run on same thread
157- } else {
158- // avoid performing blocking I/O operation on application thread
159- AgentTaskScheduler .INSTANCE .execute (featuresDiscovery ::discover );
143+ synchronized (this ) {
144+ if (featuresDiscovery == null ) {
145+ createRemaining (config );
146+ featuresDiscovery =
147+ new DDAgentFeaturesDiscovery (
148+ okHttpClient ,
149+ monitoring ,
150+ agentUrl ,
151+ config .isTraceAgentV05Enabled (),
152+ config .isTracerMetricsEnabled ());
153+
154+ if (paused ) {
155+ // defer remote discovery until remote I/O is allowed
156+ } else {
157+ if (AGENT_THREAD_GROUP .equals (Thread .currentThread ().getThreadGroup ())) {
158+ featuresDiscovery .discover (); // safe to run on same thread
159+ } else {
160+ // avoid performing blocking I/O operation on application thread
161+ AgentTaskScheduler .INSTANCE .execute (featuresDiscovery ::discover );
162+ }
163+ }
160164 }
161165 }
162166 }
You can’t perform that action at this time.
0 commit comments