-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
Describe the bug
Assume that I have:
- JAX-RS REST resource class with the GET method and some @path like for example this:
@GET
@Path("/subpath")
public String get() {
return "y";
}
As long as this is the only method on the resource (or there are some other "resource" methods with the HTTP method annotations), then HTTP method HEAD method works as expected and returns the headers for this resource. However when this class has another resource without HTTP method. For example something like this:
@Path("/zpath")
public ZResource getAnotherResource() {
return CDI.current()
.select(ZResource.class)
.get();
}
Then method HEAD on the original resource (with path /subpath
) returns "405 Method not allowed" . The GET
method on the /subpath
works as expected and returns 200 and successful response. Only the method HEAD
is broken.
Expected behavior
Method HEAD
works and returns 200
Actual behavior
Method HEAD
does not work and returns 405
How to Reproduce?
Created reproducer project here: https://github.com/mposolda/quarkus-reproducer-resteasy-head-bug
When running mvnw test
there is failing test due this bug
Output of uname -a
or ver
Linux mposolda-ThinkPad-P1-Gen-7 6.14.0-24-generic #24~24.04.3-Ubuntu SMP PREEMPT_DYNAMIC Mon Jul 7 16:39:17 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
Output of java -version
openjdk version "21.0.8" 2025-07-15 OpenJDK Runtime Environment (build 21.0.8+9-Ubuntu-0ubuntu124.04.1) OpenJDK 64-Bit Server VM (build 21.0.8+9-Ubuntu-0ubuntu124.04.1, mixed mode, sharing)
Quarkus version or git rev
3.24.5
Build tool (ie. output of mvnw --version
or gradlew --version
)
Apache Maven 3.9.8
Additional information
-
I consider this a bug as when
@HEAD
annotation is not present, there should be fallback to the@GET
according to this section of jax-rs specification - point 2 -
This was originally created as a bug in Keycloak - Getting error 405 "Method Not Allowed" when calling the "certs" endpoint with HEAD method keycloak/keycloak#41537
-
This is likely related to this issue HTTP HEAD to @GET endpoint of (reactive) Jakarta RESTful web services sub resource returns 405 #43422 . This is a follow-up to that as that issue did not fixed everything. There is probably some more tweaks needed in the class
ResourceLocatorHandler
. Basically when the line 84 returns non-null mapper, then this block is not executed, which causesHEAD
to return 405.