Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use UriInfo context in resteasy-reactive @ServerResponseFilter #458

Closed
snowdrop-bot opened this issue Dec 6, 2021 · 0 comments
Closed
Assignees
Labels
7 - Community development upstream/closed The issue has been closed in the upstream repository

Comments

@snowdrop-bot
Copy link
Collaborator

Describe the bug

According to the RESTeasy Reactive guide, filter parameters can take any context object. However, declaring UriInfo as a parameter in a response filter results in a runtime error. (This happens for a few other context objects.)

It seems that UriInfo is a valid parameter for getRequestFilterResultHandles but not for getResponseFilterResultHandles.
https://github.com/quarkusio/quarkus/blob/4757a61b87556c456724ef63f9b8fd8068b8eacd/independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/generation/filters/CustomFilterGenerator.java#L289-L293

I'm not sure if this is a documentation or implementation issue.

Expected behavior

It's possible to access UriInfo in a response filter with ContainerRequestContext#getUriInfo(). Ideally, response filters could directly declare UriInfo without error.

Actual behavior

Caused by: java.lang.RuntimeException: Parameter 'uriInfo' of method 'getFilter of class 'org.acme.Filters' is not allowed
        at io.quarkus.resteasy.reactive.server.deployment.CustomFilterGenerator.getResponseFilterResultHandles(CustomFilterGenerator.java:511)
        at io.quarkus.resteasy.reactive.server.deployment.CustomFilterGenerator.generateStandardContainerResponseFilter(CustomFilterGenerator.java:424)
        at io.quarkus.resteasy.reactive.server.deployment.CustomFilterGenerator.generateContainerResponseFilter(CustomFilterGenerator.java:336)
        at io.quarkus.resteasy.reactive.server.deployment.ResteasyReactiveScanningProcessor.handleCustomAnnotatedMethods(ResteasyReactiveScanningProcessor.java:369)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:887)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
        at java.base/java.lang.Thread.run(Thread.java:829)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)

How to Reproduce?

Create a filter class which declares javax.ws.rs.core.UriInfo as a parameter.

package org.acme;

import org.jboss.resteasy.reactive.server.ServerResponseFilter;

import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.core.UriInfo;

class Filters{
    @ServerResponseFilter
    public void getFilter(ContainerResponseContext responseContext, UriInfo uriInfo) {
        System.out.println("Request path is: " + uriInfo.getRequestUri().toString());
    }
}

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.5.1.Final

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response


quarkusio#21956


$upstream:21956$

@snowdrop-bot snowdrop-bot added the upstream/closed The issue has been closed in the upstream repository label Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
7 - Community development upstream/closed The issue has been closed in the upstream repository
Projects
None yet
Development

No branches or pull requests

2 participants