-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Describe the bug
When registering JAX-RS routes with the following structure:
@Path("/")
public class TestResource {
@GET
@Path("/administration/containers/{container}")
@Produces(MediaType.TEXT_PLAIN)
public String get(@PathParam("container") String container) {
return "/administration/containers/{container} - matched: " + container;
}
@GET
@Path("/administration/containers/boost/{type}")
@Produces(MediaType.TEXT_PLAIN)
public String boost(@PathParam("type") String type) {
return "/administration/containers/boost/{type} - matched: " + type;
}
}
The following curl requests produce unexpected results:
curl http://localhost:8080/administration/containers/boost_aaa -> 404 (INCORRECT)
curl http://localhost:8080/administration/containers/booost_aaa -> matches /administration/containers/{container} (CORRECT)
curl http://localhost:8080/administration/containers/boost/aaa -> matches /administration/containers/boost/{type} (CORRECT)
The request curl http://localhost:8080/administration/containers/boost_aaa
should match the route /administration/containers/{container}
but returns 404 instead.
Interestingly, this issue does NOT occur when using Vert.x Router directly (io.vertx.ext.web.Router
).
Workaround discovered:
The problem can be avoided by restructuring the routes with class-level @Path
:
@Path("/administration/containers")
public class TestResource {
@GET
@Path("/{container}")
@Produces(MediaType.TEXT_PLAIN)
public String get(@PathParam("container") String container) {
return "/administration/containers/{container} - matched: " + container;
}
@GET
@Path("/boost/{type}")
@Produces(MediaType.TEXT_PLAIN)
public String boost(@PathParam("type") String type) {
return "/administration/containers/boost/{type} - matched: " + type;
}
}
Expected behavior
All curl requests should work correctly:
curl http://localhost:8080/administration/containers/boost_aaa -> matches /administration/containers/{container}
curl http://localhost:8080/administration/containers/booost_aaa -> matches /administration/containers/{container}
curl http://localhost:8080/administration/containers/boost/aaa -> matches /administration/containers/boost/{type}
No 404 errors should occur for valid path parameter values.
Actual behavior
Returns 404 for curl http://localhost:8080/administration/containers/boost_aaa
instead of matching the route /administration/containers/{container}.
How to Reproduce?
- Download and run the attached project
- Start the Quarkus application
- Execute the following curl commands to observe the issue:
curl http://localhost:8080/administration/containers/boost_aaa # Returns 404 (BUG)
curl http://localhost:8080/administration/containers/booost_aaa # Works correctly
curl http://localhost:8080/administration/containers/boost/aaa # Works correctly
Output of uname -a
or ver
x86_64 macOS
Output of java -version
21.0.1
Quarkus version or git rev
3.28.1
Build tool (ie. output of mvnw --version
or gradlew --version
)
Apache Maven 3.9.11
Additional information
I'm uncertain whether this is a bug or expected behavior, since using class-level @Path("/administration/containers")
resolves the issue.