Skip to content

Commit 365bc7f

Browse files
committed
feat(asm): Restoring GOTO to avoid duplicate dispatch call when blocked
1 parent 8c79cba commit 365bc7f

File tree

1 file changed

+6
-5
lines changed
  • dd-java-agent/instrumentation/jetty-common/src/main/java/datadog/trace/instrumentation/jetty9

1 file changed

+6
-5
lines changed

dd-java-agent/instrumentation/jetty-common/src/main/java/datadog/trace/instrumentation/jetty9/HandleVisitor.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static net.bytebuddy.jar.asm.Opcodes.ALOAD;
44
import static net.bytebuddy.jar.asm.Opcodes.F_SAME;
5+
import static net.bytebuddy.jar.asm.Opcodes.GOTO;
56
import static net.bytebuddy.jar.asm.Opcodes.H_INVOKESTATIC;
67
import static net.bytebuddy.jar.asm.Opcodes.IFEQ;
78
import static net.bytebuddy.jar.asm.Opcodes.IFNE;
@@ -287,7 +288,7 @@ public void visitMethodInsn(
287288

288289
// Label doBlockLabel = new Label();
289290
Label beforeRegularDispatch = new Label();
290-
// Label afterRegularDispatch = new Label();
291+
Label afterRegularDispatch = new Label();
291292

292293
// Add current context to the stack
293294
super.visitMethodInsn(
@@ -303,7 +304,7 @@ public void visitMethodInsn(
303304
"hasRequestBlockingAction",
304305
"(" + Type.getDescriptor(Context.class) + ")Z",
305306
false);
306-
// If no request blocking action, jump befor the regular dispatch
307+
// If no request blocking action, jump before the regular dispatch
307308
super.visitJumpInsn(IFEQ, beforeRegularDispatch);
308309

309310
// super.visitVarInsn(ALOAD, CONTEXT_VAR);
@@ -386,14 +387,14 @@ public void visitMethodInsn(
386387
// invoke the dispatch method
387388
super.visitMethodInsn(opcode, owner, name, descriptor, isInterface);
388389

389-
// super.visitJumpInsn(GOTO, afterRegularDispatch);
390+
super.visitJumpInsn(GOTO, afterRegularDispatch);
390391

391392
super.visitLabel(beforeRegularDispatch);
392393
super.visitFrame(F_SAME, 0, null, 0, null);
393394
mv.commitVisitations(savedVisitations);
394395
super.visitMethodInsn(opcode, owner, name, descriptor, isInterface);
395-
// super.visitLabel(afterRegularDispatch);
396-
// super.visitFrame(F_SAME, 0, null, 0, null);
396+
super.visitLabel(afterRegularDispatch);
397+
super.visitFrame(F_SAME, 0, null, 0, null);
397398
this.success = true;
398399
return;
399400
}

0 commit comments

Comments
 (0)