quarkus icon indicating copy to clipboard operation
quarkus copied to clipboard

@Path mapping path doesn't work as expecting

Open zhonghuali opened this issue 3 years ago • 1 comments

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

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 avatar Aug 05 '22 07:08 zhonghuali

/cc @FroMage, @stuartwdouglas

quarkus-bot[bot] avatar Aug 05 '22 07:08 quarkus-bot[bot]

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.

ctron avatar Sep 13 '22 15:09 ctron