quarkusio/quarkus · error · IllegalStateException
Calling 'abortWith' is not permitted when using @ServerReque
Error message
Calling 'abortWith' is not permitted when using @ServerRequestFilter or @ServerResponseFilter. If you need to abort processing, consider returning 'Response' or 'Uni<Response>'
What it means
When a method annotated with @ServerRequestFilter/@ServerResponseFilter runs, RESTEasy Reactive wraps the ContainerRequestContext in PreventAbortResteasyReactiveContainerRequestContext, which forbids abortWith. Filters must signal abortion by returning Response (or Uni<Response>) instead of manipulating the JAX-RS abort state; violating this throws IllegalStateException.
Source
Thrown at independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/filters/PreventAbortResteasyReactiveContainerRequestContext.java:160
@Override
public void setEntityStream(InputStream input) {
delegate.setEntityStream(input);
}
@Override
public SecurityContext getSecurityContext() {
return delegate.getSecurityContext();
}
@Override
public void setSecurityContext(SecurityContext context) {
delegate.setSecurityContext(context);
}
@Override
public void abortWith(Response response) {
throw new IllegalStateException(
"Calling 'abortWith' is not permitted when using @ServerRequestFilter or @ServerResponseFilter. If you need to abort processing, consider returning 'Response' or 'Uni<Response>'");
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Change the filter to return Response instead: `public Response filter(ContainerRequestContext ctx) { return Response.status(401).build(); }` (returning non-null aborts the request).
- Return Uni<Response> for asynchronous aborts.
- Move the abortWith-based logic into a classic ContainerRequestFilter (@Provider) if you must use abortWith.
- Refactor shared helper methods to return an Optional<Response> the filter returns rather than calling abortWith.
Example fix
// before
@ServerRequestFilter
public void filter(ContainerRequestContext ctx) {
if (!authorized(ctx)) ctx.abortWith(Response.status(401).build());
}
// after
@ServerRequestFilter
public Response filter(ContainerRequestContext ctx) {
if (!authorized(ctx)) return Response.status(401).build();
return null; // continue
} Defensive patterns
Strategy: try-catch
Try / catch
// avoid triggering; if calling legacy filter code, guard:
try {
legacyFilter.filter(requestContext);
} catch (IllegalStateException e) {
if (e.getMessage() != null && e.getMessage().contains("abortWith")) {
log.warn("Legacy filter attempted abortWith inside @ServerRequestFilter");
} else throw e;
} Prevention
- In @ServerRequestFilter, always abort by returning Response / Uni<Response>.
- Audit migrated JAX-RS filters for abortWith calls.
- Keep legacy ContainerRequestFilters as @Provider beans, not @ServerRequestFilter, if they need abortWith.
When it happens
Trigger: Inside a @ServerRequestFilter method, calling ContainerRequestContext.abortWith(response) (directly or via legacy code reused from a @PreMatching/@NameBinding filter).
Common situations: Migrating classic JAX-RS ContainerRequestFilter code into a @ServerRequestFilter without adapting the abort logic; shared filter helper that calls abortWith unconditionally.
Related errors
- ${className} class reading failed
- The combination of '@${annotationName}' and '@ServerRequestF
- Method '${info.name()} of class '${info.declaringClass().nam
- Method '${info.name()} of class '${info.declaringClass().nam
- Method '${targetMethod.name()} of class '${targetMethod.decl
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/c71ef92b0dc26c02.
Report an issue: GitHub.