Skip to content

Commit

Permalink
Use OnMethodEnter for blocking sessions in vert.x (#8225)
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-alvarez-alvarez authored Jan 16, 2025
1 parent 296ed7b commit ae1aa30
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)");
}
}
}

0 comments on commit ae1aa30

Please sign in to comment.