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

List<PathSegment> exception on RESTEasy Reactive #17034

Closed
tedwon opened this issue May 6, 2021 · 4 comments · Fixed by #20995
Closed

List<PathSegment> exception on RESTEasy Reactive #17034

tedwon opened this issue May 6, 2021 · 4 comments · Fixed by #20995
Labels
area/rest kind/bug Something isn't working
Milestone

Comments

@tedwon
Copy link
Contributor

tedwon commented May 6, 2021

Describe the bug

As I asked in Zulip, I wanted to use List<PathSegment> with RESTEasy Reactive extension to use @PathParam and Regular Expressions. i.e. @path("{keyword:.*}")
https://docs.jboss.org/resteasy/docs/4.6.0.Final/userguide/html_single/index.html#_PathParam_and_PathSegment

But I'm getting exceptions as below:
https://github.com/tedwon/quarkus-resteasy-reactive-with-pathsegment/blob/master/README.adoc

It is working properly with @PathParam("id") PathSegment id:
https://github.com/tedwon/quarkus-resteasy-reactive-with-pathsegment/blob/master/src/main/java/org/acme/getting/started/ReactiveGreetingResource.java#L51-L55

However, getting errors java.lang.RuntimeException: Failed to find converter for javax.ws.rs.core.PathSegment with @PathParam("keyword") List<PathSegment> keywords while startup Quarkus.
https://github.com/tedwon/quarkus-resteasy-reactive-with-pathsegment/blob/master/src/main/java/org/acme/getting/started/ReactiveGreetingResource.java#L57-L61

Note that it is working properly for the same code with List on my other Quarkus app with quarkus-resteasy extension.

Expected behavior

No exception for the usage of List with quarkus-resteasy extension

Actual behavior

2021-05-02 02:16:02,416 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.resteasy.reactive.server.deployment.ResteasyReactiveProcessor#setupEndpoints threw an exception: java.lang.RuntimeException: java.lang.RuntimeException: Failed to process method org.acme.getting.started.ReactiveGreetingResource#java.lang.String searchByKeywords(java.util.List<javax.ws.rs.core.PathSegment> keywords)
	at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createEndpoints(EndpointIndexer.java:238)
	at io.quarkus.resteasy.reactive.server.deployment.ResteasyReactiveProcessor.setupEndpoints(ResteasyReactiveProcessor.java:402)
	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:920)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2415)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
	at java.base/java.lang.Thread.run(Thread.java:834)
	at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: java.lang.RuntimeException: Failed to process method org.acme.getting.started.ReactiveGreetingResource#java.lang.String searchByKeywords(java.util.List<javax.ws.rs.core.PathSegment> keywords)
	at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createResourceMethod(EndpointIndexer.java:524)
	at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createEndpoints(EndpointIndexer.java:285)
	at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createEndpoints(EndpointIndexer.java:209)
	... 11 more
Caused by: java.lang.RuntimeException: Failed to find converter for javax.ws.rs.core.PathSegment
	at io.quarkus.resteasy.reactive.server.deployment.QuarkusServerEndpointIndexer.extractConverter(QuarkusServerEndpointIndexer.java:198)
	at org.jboss.resteasy.reactive.server.processor.ServerEndpointIndexer.handleListParam(ServerEndpointIndexer.java:277)
	at org.jboss.resteasy.reactive.server.processor.ServerEndpointIndexer.handleListParam(ServerEndpointIndexer.java:57)
	at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.extractParameterInfo(EndpointIndexer.java:909)
	at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createResourceMethod(EndpointIndexer.java:407)
	... 13 more

To Reproduce

Please run this reproducer project:
https://github.com/tedwon/quarkus-resteasy-reactive-with-pathsegment

./mvnw quarkus:dev

Quarkus version or git rev

QUARKUS 1.13.3

@tedwon tedwon added the kind/bug Something isn't working label May 6, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented May 6, 2021

/cc @FroMage, @geoand, @stuartwdouglas

@quarkus-bot quarkus-bot bot added the area/rest label May 6, 2021
@geoand geoand self-assigned this May 6, 2021
@geoand
Copy link
Contributor

geoand commented May 6, 2021

Can you give an example of how you expect this to work?
Furthermore, does it work with RESTEasy Classic?

@FroMage
Copy link
Member

FroMage commented May 10, 2021

I thought this would be confusing at first too, but the spec gives this example: https://quarkus.io/specs/jaxrs/2.1/index.html#uritemplates

With @Path("widgets/{path:.+}") given the request path widgets/small/a the value of path would be small/a.

From which we can guess that a List<PathSegment> of those would have two entries: one for small and one for a.

Either the TCK doesn't test for this, or we disabled that test. Not sure how easy it would be to support this, or how useful.

I wonder if it would make as much sense to support List<String> and other collections for @PathParam if there's a regex in the URI template.

@gastaldi
Copy link
Contributor

I'm facing the same error while trying to convert registry.quarkus.io to RestEasy Reactive.
This is the endpoint:

    @GET
    @Path("{path:.+}")
    public Response handleArtifactRequest(
            @PathParam("path") List<PathSegment> pathSegments,
            @Context UriInfo uriInfo) {
			...
    }

stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Oct 25, 2021
stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Oct 26, 2021
stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Oct 26, 2021
@geoand geoand removed their assignment Oct 26, 2021
@quarkus-bot quarkus-bot bot added this to the 2.5 - main milestone Oct 26, 2021
@gsmet gsmet modified the milestones: 2.5 - main, 2.4.1.Final Nov 2, 2021
gsmet pushed a commit to gsmet/quarkus that referenced this issue Nov 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/rest kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants