I tried RESTEasy's (WildFly 16) abortWith(Response response) but did not work. I have multiple abortWith medhods. Such as,
if(fails1){
System.out.printn("fails 1");
abortWith(...)
}
if(fails2){
System.out.printn("fails 2");
abortWith(...);
}
If fails1 and fails2 are true, both abortWith methods are executed. The fails1's abortWith does not return response unless I put "return".
if(fails1){
System.out.printn("fails 1");
abortWith(...);
return;
}
Do I need to put return after abortWith? Can I throw WebApplicationException to break filter chain?
The ContainerRequestContext.abortWith()
aborts the filter chain, not the current filter being processed. You can either add the return statement like you suggest or throw a WebApplicationException
to raise and exception.