Skip to content

Commit d3775d4

Browse files
committed
Revert "Lazily generate PropagationContext"
This reverts commit 398c5df.
1 parent 188f500 commit d3775d4

File tree

1 file changed

+7
-25
lines changed

1 file changed

+7
-25
lines changed

sentry/src/main/java/io/sentry/Scope.java

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import io.sentry.util.CollectionUtils;
1212
import io.sentry.util.EventProcessorUtils;
1313
import io.sentry.util.ExceptionUtils;
14-
import io.sentry.util.LazyEvaluator;
1514
import io.sentry.util.Objects;
1615
import io.sentry.util.Pair;
1716
import java.lang.ref.WeakReference;
@@ -94,7 +93,7 @@ public final class Scope implements IScope {
9493
/** Scope's attachments */
9594
private @NotNull List<Attachment> attachments = new CopyOnWriteArrayList<>();
9695

97-
private @NotNull LazyEvaluator<PropagationContext> propagationContext;
96+
private @NotNull PropagationContext propagationContext;
9897

9998
/** Scope's session replay id */
10099
private @NotNull SentryId replayId = SentryId.EMPTY_ID;
@@ -112,14 +111,7 @@ public final class Scope implements IScope {
112111
public Scope(final @NotNull SentryOptions options) {
113112
this.options = Objects.requireNonNull(options, "SentryOptions is required.");
114113
this.breadcrumbs = createBreadcrumbsList(this.options.getMaxBreadcrumbs());
115-
this.propagationContext =
116-
new LazyEvaluator<>(
117-
new LazyEvaluator.Evaluator<PropagationContext>() {
118-
@Override
119-
public @NotNull PropagationContext evaluate() {
120-
return new PropagationContext();
121-
}
122-
});
114+
this.propagationContext = new PropagationContext();
123115
this.lastEventId = SentryId.EMPTY_ID;
124116
}
125117

@@ -132,15 +124,6 @@ private Scope(final @NotNull Scope scope) {
132124
this.client = scope.client;
133125
this.lastEventId = scope.getLastEventId();
134126

135-
this.propagationContext =
136-
new LazyEvaluator<>(
137-
new LazyEvaluator.Evaluator<PropagationContext>() {
138-
@Override
139-
public @NotNull PropagationContext evaluate() {
140-
return new PropagationContext();
141-
}
142-
});
143-
144127
final User userRef = scope.user;
145128
this.user = userRef != null ? new User(userRef) : null;
146129
this.screen = scope.screen;
@@ -190,7 +173,7 @@ private Scope(final @NotNull Scope scope) {
190173

191174
this.attachments = new CopyOnWriteArrayList<>(scope.attachments);
192175

193-
this.propagationContext.setValue(new PropagationContext(scope.propagationContext.getValue()));
176+
this.propagationContext = new PropagationContext(scope.propagationContext);
194177
}
195178

196179
/**
@@ -1082,7 +1065,7 @@ public void clearSession() {
10821065
@ApiStatus.Internal
10831066
@Override
10841067
public void setPropagationContext(final @NotNull PropagationContext propagationContext) {
1085-
this.propagationContext.setValue(propagationContext);
1068+
this.propagationContext = propagationContext;
10861069

10871070
final @NotNull SpanContext spanContext = propagationContext.toSpanContext();
10881071
for (final IScopeObserver observer : options.getScopeObservers()) {
@@ -1093,17 +1076,16 @@ public void setPropagationContext(final @NotNull PropagationContext propagationC
10931076
@ApiStatus.Internal
10941077
@Override
10951078
public @NotNull PropagationContext getPropagationContext() {
1096-
return propagationContext.getValue();
1079+
return propagationContext;
10971080
}
10981081

10991082
@ApiStatus.Internal
11001083
@Override
11011084
public @NotNull PropagationContext withPropagationContext(
11021085
final @NotNull IWithPropagationContext callback) {
11031086
try (final @NotNull ISentryLifecycleToken ignored = propagationContextLock.acquire()) {
1104-
final @NotNull PropagationContext context = getPropagationContext();
1105-
callback.accept(context);
1106-
return new PropagationContext(context);
1087+
callback.accept(propagationContext);
1088+
return new PropagationContext(propagationContext);
11071089
}
11081090
}
11091091

0 commit comments

Comments
 (0)