Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Plugged a few gaps in token handling for error path cases #1978

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public void onComplete() {

public void onNext(T t) {
if (token != null) {
// not ideal to do this in onNext, but we're seeing situations where nothing else is ever called
// no onComplete, no onError, no cancel
token.linkAndExpire();
token = null;
}
Expand All @@ -54,5 +56,13 @@ public void onError(Throwable t) {
}
Weaver.callOriginal();
}

public void cancel() {
if (token != null) {
token.linkAndExpire();
token = null;
}
Weaver.callOriginal();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ public final void onError(Throwable t) {
Weaver.callOriginal();
}

public void dispose() {
Token token = this.currentContext().getOrDefault("newrelic-token", null);
if (token != null) {
token.expire();
this.nrContext = null;
}
Weaver.callOriginal();
}

public Context currentContext() {
if (nrContext != null) {
return initialContext.putAll(nrContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ public final void onError(Throwable t) {
Weaver.callOriginal();
}

public void dispose() {
Token token = this.currentContext().getOrDefault("newrelic-token", null);
if (token != null) {
token.expire();
this.nrContext = null;
}
Weaver.callOriginal();
}

public Context currentContext() {
if (nrContext != null) {
//return nrContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
abstract class MonoSubscribeOn_Instrumentation {

@Weave(type = MatchType.ExactClass, originalName = "reactor.core.publisher.MonoSubscribeOn$SubscribeOnSubscriber")
static final class SubscribeOnSubscriber_Instrumentation {
static final class SubscribeOnSubscriber_Instrumentation<T> {
@NewField
private Token token;

Expand All @@ -32,7 +32,31 @@ static final class SubscribeOnSubscriber_Instrumentation {

public void run () {
if (token != null) {
Boolean result = token.linkAndExpire();
token.linkAndExpire();
token = null;
}
Weaver.callOriginal();
}

public void onNext(T t) {
if (token != null) {
token.linkAndExpire();
token = null;
}
Weaver.callOriginal();
}

public void onComplete() {
if (token != null) {
token.linkAndExpire();
token = null;
}
Weaver.callOriginal();
}

public void onError(Throwable t) {
if (token != null) {
token.linkAndExpire();
token = null;
}
Weaver.callOriginal();
Expand Down
Loading