File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
agent/agent/src/main/java/com/microsoft/applicationinsights/agent Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change 2323
2424import io .opentelemetry .javaagent .OpenTelemetryAgent ;
2525import java .lang .instrument .Instrumentation ;
26+ import java .util .concurrent .atomic .AtomicBoolean ;
2627
2728// IMPORTANT!! If this class is renamed, be sure to add the previous name to
2829// DuplicateAgentClassFileTransformer
@@ -34,10 +35,10 @@ public class Agent {
3435 // this is to prevent the agent from loading and instrumenting everything twice
3536 // (leading to unpredictable results) when -javaagent:applicationinsights-agent.jar
3637 // appears multiple times on the command line
37- private static volatile boolean alreadyLoaded ;
38+ private static final AtomicBoolean alreadyLoaded = new AtomicBoolean ( false ) ;
3839
3940 public static void premain (String agentArgs , Instrumentation inst ) {
40- if (alreadyLoaded ) {
41+ if (alreadyLoaded . getAndSet ( true ) ) {
4142 return ;
4243 }
4344
@@ -46,7 +47,6 @@ public static void premain(String agentArgs, Instrumentation inst) {
4647 }
4748
4849 OpenTelemetryAgent .premain (agentArgs , inst );
49- alreadyLoaded = true ;
5050 }
5151
5252 // this is provided only for dynamic attach in the first line of main
You can’t perform that action at this time.
0 commit comments