Skip to content

Commit

Permalink
Replace AtomicBoolean with volatile boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
laurit committed Mar 3, 2021
1 parent 64d846e commit 754ecc3
Showing 1 changed file with 3 additions and 4 deletions.
Expand Up @@ -7,7 +7,6 @@

import io.opentelemetry.context.Context;
import io.opentelemetry.context.ContextKey;
import java.util.concurrent.atomic.AtomicBoolean;

/**
* Helper container for tracking whether servlet integration should update server span name or not.
Expand All @@ -24,7 +23,7 @@ public static Context init(Context context) {
return context.with(CONTEXT_KEY, new ServletSpanNaming());
}

private final AtomicBoolean servletUpdatedServerSpanName = new AtomicBoolean(false);
private volatile boolean servletUpdatedServerSpanName = false;

private ServletSpanNaming() {}

Expand All @@ -40,7 +39,7 @@ private ServletSpanNaming() {}
public static boolean shouldUpdateServerSpanName(Context context) {
ServletSpanNaming servletSpanNaming = context.get(CONTEXT_KEY);
if (servletSpanNaming != null) {
return !servletSpanNaming.servletUpdatedServerSpanName.get();
return !servletSpanNaming.servletUpdatedServerSpanName;
}
return false;
}
Expand All @@ -53,7 +52,7 @@ public static boolean shouldUpdateServerSpanName(Context context) {
public static void setServletUpdatedServerSpanName(Context context) {
ServletSpanNaming servletSpanNaming = context.get(CONTEXT_KEY);
if (servletSpanNaming != null) {
servletSpanNaming.servletUpdatedServerSpanName.set(true);
servletSpanNaming.servletUpdatedServerSpanName = true;
}
}
}

0 comments on commit 754ecc3

Please sign in to comment.