From ae1aa30548a1c4421843c80f16cd5e6aef088db0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20=C3=81lvarez=20=C3=81lvarez?= Date: Thu, 16 Jan 2025 12:39:16 +0100 Subject: [PATCH] Use OnMethodEnter for blocking sessions in vert.x (#8225) --- .../vertx_3_4/server/RoutingContextSessionAdvice.java | 9 +++------ .../vertx_4_0/server/RoutingContextSessionAdvice.java | 9 +++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/dd-java-agent/instrumentation/vertx-web-3.4/src/main/java/datadog/trace/instrumentation/vertx_3_4/server/RoutingContextSessionAdvice.java b/dd-java-agent/instrumentation/vertx-web-3.4/src/main/java/datadog/trace/instrumentation/vertx_3_4/server/RoutingContextSessionAdvice.java index 866e9c71ffa..4a7948188ea 100644 --- a/dd-java-agent/instrumentation/vertx-web-3.4/src/main/java/datadog/trace/instrumentation/vertx_3_4/server/RoutingContextSessionAdvice.java +++ b/dd-java-agent/instrumentation/vertx-web-3.4/src/main/java/datadog/trace/instrumentation/vertx_3_4/server/RoutingContextSessionAdvice.java @@ -17,11 +17,10 @@ @RequiresRequestContext(RequestContextSlot.APPSEC) class RoutingContextSessionAdvice { - @Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class) + @Advice.OnMethodEnter(suppress = Throwable.class) static void after( @ActiveRequestContext final RequestContext reqCtx, - @Advice.Argument(0) final Session session, - @Advice.Thrown(readOnly = false) Throwable throwable) { + @Advice.Argument(0) final Session session) { if (session == null) { return; @@ -47,9 +46,7 @@ static void after( rba.getStatusCode(), rba.getBlockingContentType(), rba.getExtraHeaders()); - if (throwable == null) { - throwable = new BlockingException("Blocked request (for session)"); - } + throw new BlockingException("Blocked request (for session)"); } } } diff --git a/dd-java-agent/instrumentation/vertx-web-4.0/src/main/java/datadog/trace/instrumentation/vertx_4_0/server/RoutingContextSessionAdvice.java b/dd-java-agent/instrumentation/vertx-web-4.0/src/main/java/datadog/trace/instrumentation/vertx_4_0/server/RoutingContextSessionAdvice.java index 2824822b3be..69ef46fbdf7 100644 --- a/dd-java-agent/instrumentation/vertx-web-4.0/src/main/java/datadog/trace/instrumentation/vertx_4_0/server/RoutingContextSessionAdvice.java +++ b/dd-java-agent/instrumentation/vertx-web-4.0/src/main/java/datadog/trace/instrumentation/vertx_4_0/server/RoutingContextSessionAdvice.java @@ -17,11 +17,10 @@ @RequiresRequestContext(RequestContextSlot.APPSEC) class RoutingContextSessionAdvice { - @Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class) + @Advice.OnMethodEnter(suppress = Throwable.class) static void after( @ActiveRequestContext final RequestContext reqCtx, - @Advice.Argument(0) final Session session, - @Advice.Thrown(readOnly = false) Throwable throwable) { + @Advice.Argument(0) final Session session) { if (session == null) { return; @@ -47,9 +46,7 @@ static void after( rba.getStatusCode(), rba.getBlockingContentType(), rba.getExtraHeaders()); - if (throwable == null) { - throwable = new BlockingException("Blocked request (for session)"); - } + throw new BlockingException("Blocked request (for session)"); } } }