When using RESTEasy Reactive, when we try to use requestContext.getUriInfo() in a @ServiceResponseFilter after an abort has been made in a @ServerRequestFilter (return Uni.createFrom().item(Response.status(401).build())), there is a null pointer exception happening, when calling request.getUriInfo() in the response filter.
Expected behavior
The service should return a proper response when the request has been aborted at the authentication phase.
Darwin 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64 x86_64
Output of java -version
openjdk version "11.0.10" 2021-01-19 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.10+9) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.10+9, mixed mode)
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.0.3
Build tool (ie. output of mvnw --version or gradlew --version)
Apache Maven 3.8.1
Additional information
It seems that when using RESTEasy Reactive and abort the request inside an authorization filter, the UriInfo is being lost when it arrives at the response filter.
After some deeper research, we found that the target element (of type RuntimeResource) of the request context is also lost when it leaves the request filter (not sure it was supposed to be this way). It is present during the request filter.
If we call requestContext.getUriInfo().getPathParameters(); on the request filter, the target element will still not be available inside the response filter, but at least the UriInfo would have been calculated from a previous step, and it will be available.
Describe the bug
When using RESTEasy Reactive, when we try to use
requestContext.getUriInfo()
in a@ServiceResponseFilter
after an abort has been made in a@ServerRequestFilter
(return Uni.createFrom().item(Response.status(401).build())
), there is a null pointer exception happening, when callingrequest.getUriInfo()
in the response filter.Expected behavior
The service should return a proper response when the request has been aborted at the authentication phase.
Actual behavior
The service crashes with a NullPointerException
How to Reproduce?
FirstFilter
class and put line 23 in commentsGET http://localhost:8080/authentication/secured-with-jwt
againfilter-study.zip
Output of
uname -a
orver
Darwin 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64 x86_64
Output of
java -version
openjdk version "11.0.10" 2021-01-19 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.10+9) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.10+9, mixed mode)
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.0.3
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.8.1
Additional information
It seems that when using RESTEasy Reactive and abort the request inside an authorization filter, the
UriInfo
is being lost when it arrives at the response filter.After some deeper research, we found that the
target
element (of typeRuntimeResource
) of the request context is also lost when it leaves the request filter (not sure it was supposed to be this way). It is present during the request filter.If we call
requestContext.getUriInfo().getPathParameters();
on the request filter, thetarget
element will still not be available inside the response filter, but at least the UriInfo would have been calculated from a previous step, and it will be available.https://github.com/quarkusio/quarkus/issues/18990
$upstream:18990$