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

JAX-RS sub-resource locators with parameter don't always match #26028

Closed
Emmeral opened this issue Jun 9, 2022 · 7 comments · Fixed by #26224
Closed

JAX-RS sub-resource locators with parameter don't always match #26028

Emmeral opened this issue Jun 9, 2022 · 7 comments · Fixed by #26224
Labels
area/resteasy-reactive kind/bug Something isn't working
Milestone

Comments

@Emmeral
Copy link
Contributor

Emmeral commented Jun 9, 2022

Describe the bug

When using JAX-RS resource locators and sub-resources I don't always get the expected behavior. The paths don't match as expected. If you have a resource locator annotated with @Path("{id}SomethingElse") and a nested path in the sub-resource, quarkus will not match the path but rather output a 404.

I think this is related to this line in the URITemplate class. Or more specifically that the URITemplate is mistakenly constructed with prefixMatch set to false. It should be set to true as the path only refers to a resource locator and not an actual method. Sadly I could not inspect further from where the constructor is called.

Expected behavior

Referring to code posted below

If I request GET /b/TomOther/greet I expect to get returned Hello Tom (same as when calling GET /a/Tom/greet)

Actual behavior

I get 404 - Resource Not Found status code.

How to Reproduce?

Repository or see code below

import javax.ws.rs.Path;
import javax.ws.rs.container.ResourceContext;
import javax.ws.rs.core.Context;

@Path("/")
public class RootResource {

    @Context
    ResourceContext resourceContext;

    @Path("a/{id}")
    public SubResource sub() {
        return resourceContext.getResource(SubResource.class);
    }

    @Path("b/{id}Other")
    public SubResource sub2() {
        return resourceContext.getResource(SubResource.class);
    }
}
import io.quarkus.arc.Unremovable;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;


@Unremovable
@RequestScoped
@Produces("text/plain")
public class SubResource {



    @Path("/greet")
    @GET
    public String greet(@PathParam("id") String id){
        return "Hello " + id;
    }


}

Output of uname -a or ver

No response

Output of java -version

openjdk version "11.0.13" 2021-10-19

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.9.2.Final

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

No response

Additional information

No response

@Emmeral Emmeral added the kind/bug Something isn't working label Jun 9, 2022
@Emmeral Emmeral changed the title JAX-RS Subresource Locators with parameter don't always match JAX-RS sub-resource locators with parameter don't always match Jun 9, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Jun 10, 2022

/cc @FroMage, @stuartwdouglas

@geoand
Copy link
Contributor

geoand commented Jun 10, 2022

Since you have already analyzed the code, would you like to provide a Pull Request with your proposed change?

@Emmeral
Copy link
Contributor Author

Emmeral commented Jun 13, 2022

Sadly I did not find the origin of the constructor call. I think it is related to some code which is generated at build time, so my IDE could not resolve the source.

@geoand
Copy link
Contributor

geoand commented Jun 13, 2022

Can you attach a sample project?

@Emmeral
Copy link
Contributor Author

Emmeral commented Jun 13, 2022

I already did in the original Issue.
But here is the link again.

@Emmeral
Copy link
Contributor Author

Emmeral commented Jun 14, 2022

I further looked into the issue and I think I found the responsible constructor call. I fixed it in #26115

@Emmeral
Copy link
Contributor Author

Emmeral commented Jun 20, 2022

Added a new PR to the correct base branch. See #26224

@quarkus-bot quarkus-bot bot added this to the 2.11 - main milestone Jun 20, 2022
@gsmet gsmet modified the milestones: 2.11 - main, 2.10.1.Final Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/resteasy-reactive kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants