Skip to content

Conversation

@laurit
Copy link
Contributor

@laurit laurit commented Oct 13, 2021

Part of #3916

@Advice.OnMethodEnter(suppress = Throwable.class)
public static Scope onEnter() {
if (Java8BytecodeBridge.currentContext() != Java8BytecodeBridge.rootContext()) {
return Java8BytecodeBridge.rootContext().makeCurrent();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it forcefully removes the current context for while the method executes; this way preventing the context leaking into a (potentially long-running) task that's started there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will everybody understand that in a year while reading this code? :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's wait a year and see 🤣
But yeah, a comment here explaining why we're doing such a thing would be invaluable.

@Advice.OnMethodEnter(suppress = Throwable.class)
public static Scope onEnter() {
if (Java8BytecodeBridge.currentContext() != Java8BytecodeBridge.rootContext()) {
return Java8BytecodeBridge.rootContext().makeCurrent();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it forcefully removes the current context for while the method executes; this way preventing the context leaking into a (potentially long-running) task that's started there.

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@trask trask merged commit 72d3c33 into open-telemetry:main Oct 13, 2021
RashmiRam pushed a commit to RashmiRam/opentelemetry-auto-instr-java that referenced this pull request May 23, 2022
* PlayWS strict context check

* add comment
@laurit laurit deleted the playws-strict-context-check branch July 6, 2023 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants