Skip to content

Commit

Permalink
Fix flaky jaxrs async test (#6523)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurit committed Sep 2, 2022
1 parent 0b5a22c commit 79acca7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,13 @@ public static void stopSpan(

CompletionStage<?> asyncReturnValue =
returnValue instanceof CompletionStage ? (CompletionStage<?>) returnValue : null;

if (asyncResponse != null && !asyncResponse.isSuspended()) {
// Clear span from the asyncResponse. Logically this should never happen. Added to be safe.
VirtualField.find(AsyncResponse.class, AsyncResponseData.class).set(asyncResponse, null);
}
if (asyncReturnValue != null) {
// span finished by CompletionStageFinishCallback
asyncReturnValue =
asyncReturnValue.handle(
new CompletionStageFinishCallback<>(instrumenter(), context, handlerData));
}
if ((asyncResponse == null || !asyncResponse.isSuspended()) && asyncReturnValue == null) {
if (asyncResponse == null && asyncReturnValue == null) {
instrumenter().end(context, handlerData, null, null);
}
// else span finished by AsyncResponse*Advice
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,13 @@ public static void stopSpan(

CompletionStage<?> asyncReturnValue =
returnValue instanceof CompletionStage ? (CompletionStage<?>) returnValue : null;

if (asyncResponse != null && !asyncResponse.isSuspended()) {
// Clear span from the asyncResponse. Logically this should never happen. Added to be safe.
VirtualField.find(AsyncResponse.class, AsyncResponseData.class).set(asyncResponse, null);
}
if (asyncReturnValue != null) {
// span finished by CompletionStageFinishCallback
asyncReturnValue =
asyncReturnValue.handle(
new CompletionStageFinishCallback<>(instrumenter(), context, handlerData));
}
if ((asyncResponse == null || !asyncResponse.isSuspended()) && asyncReturnValue == null) {
if (asyncResponse == null && asyncReturnValue == null) {
instrumenter().end(context, handlerData, null, null);
}
// else span finished by AsyncResponse*Advice
Expand Down

0 comments on commit 79acca7

Please sign in to comment.