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

@Path mapping path doesn't work as expecting #27154

Closed
zhonghuali opened this issue Aug 5, 2022 · 2 comments · Fixed by #30695
Closed

@Path mapping path doesn't work as expecting #27154

zhonghuali opened this issue Aug 5, 2022 · 2 comments · Fixed by #30695
Labels
area/rest kind/bug Something isn't working
Milestone

Comments

@zhonghuali
Copy link

zhonghuali commented Aug 5, 2022

Describe the bug

the resteasy reactive @path mapping have confused behaivours in my cases.

please see the reproduced steps

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

Steps:

  1. git clone https://github.com/quarkusio/quarkus-quickstarts.git with latest version
  2. cd quarkus-quickstarts\getting-started-reactive
  3. changed the file src\main\java\org\acme\getting\started\ReactiveGreetingResource.java
@Path("")
public class ReactiveGreetingResource {

    @Inject
    ReactiveGreetingService service;

    @Path("{name}")
    @POST
    public Uni<String> allPath(@RestPath String name) {
        System.out.println("I'm in all path method");
        return service.greeting(name);
    }
    @Path("get/{name}")
    public Uni<String> getPath(@RestPath String name) {
        System.out.println("I'm in get path method");
        return service.greeting(name);
    }

....
4. mvn quarkus:dev
5. excute curl to access the mapping uri
a. curl -v -X GET http://localhost:8080/get/a
the result works as expecting, @path("get/{name}") was hit ,@path("{name}") was not hit.
but the returned status is 405 Method Not Allowed. it might also a issue.

curl -v -X POST http://localhost:8080/get/a. hava same return.

b. curl -v -X POST http://localhost:8080/ge
the result works as expecting, @path("get/{name}") was not hit ,@path("{name}") was hit
c. curl -v -X POST http://localhost:8080/getas
the result behaivor is confused. there are not one uri path to hit . returned 404
I think @path("{name}") shoud be hit
d. curl -v -X POST http://localhost:8080/get
the result behaivor is also confused. there are not one uri path to hit . returned 404
I think @path("{name}") shoud be hit

e. added one more user case, it's more important. !!! NEW
curl -v -X POST http://localhost:8080/hello
the result is :HTTP/1.1 406 Not Acceptable
if you use the swagger ui in this example, it's same because it also use curl command.
But if you use Postman tool to access the url http://localhost:8080/hello, you get the right result!!!
It blocked test!!

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

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

No response

Additional information

whole codes in src\main\java\org\acme\getting\started\ReactiveGreetingResource.java

package org.acme.getting.started;

import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import io.smallrye.mutiny.Multi;
import io.smallrye.mutiny.Uni;

import org.jboss.resteasy.reactive.RestPath;
import org.jboss.resteasy.reactive.RestSseElementType;

@Path("")
public class ReactiveGreetingResource {

    @Inject
    ReactiveGreetingService service;

    @Path("{name}")
    @POST
    public Uni<String> allPath(@RestPath String name) {
        System.out.println("I'm in all path method");
        return service.greeting(name);
    }
    @Path("get/{name}")
    public Uni<String> getPath(@RestPath String name) {
        System.out.println("I'm in get path method");
        return service.greeting(name);
    }

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    @Path("/greeting/{name}")
    public Uni<String> greeting(String name) {
        return service.greeting(name);
    }

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    @Path("/greeting/{count}/{name}")
    public Multi<String> greetings(int count, String name) {
        return service.greetings(count, name);
    }

    @GET
    @Produces(MediaType.SERVER_SENT_EVENTS)
    @RestSseElementType(MediaType.TEXT_PLAIN)
    @Path("/stream/{count}/{name}")
    public Multi<String> greetingsAsStream(int count, String name) {
        return service.greetings(count, name);
    }

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String hello() {
        return "hello";
    }
}
@zhonghuali zhonghuali added the kind/bug Something isn't working label Aug 5, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Aug 5, 2022

/cc @FroMage, @stuartwdouglas

@ctron
Copy link
Contributor

ctron commented Sep 13, 2022

Please ignore my previous comment (deleted it). The 404 error was coming from an 404 exception, which bubbled up the chain. Unfortunately it wasn't possible (at least to me) to distinguish it from a "404 page not found" case.

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
3 participants