snowdrop-zen / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
1 stars 0 forks source link

NPE with `getUriInfo()` after aborting a request during the Authorization step in RESTEasy Reactive #387

Closed snowdrop-bot closed 3 years ago

snowdrop-bot commented 3 years ago

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 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.

Actual behavior

The service crashes with a NullPointerException

How to Reproduce?

filter-study.zip

Output of uname -a or ver

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.


https://github.com/quarkusio/quarkus/issues/18990


$upstream:18990$