quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.76k stars 2.68k forks source link

MessageBodyWriter is not used with null Accept header with quarkus-resteasy #42854

Open jcarranzan opened 2 months ago

jcarranzan commented 2 months ago

Describe the bug

Verifying backport for 3.8.6 https://github.com/quarkusio/quarkus/pull/41411- Ensure that MessageBodyWriter is passed the proper media type and doing a small test coverage in our quarkus test suite, I've noticed that it's not working with quarkus-resteasy, not sure if it's the behavior expected.

Expected behavior

It works same as with quarkus-rest dependency

Actual behavior

MessageBodyWriter<String> is ignored and then the response is not expected.

How to Reproduce?

  1. Clone my reproducer: git clone -b accept-no-header https://github.com/jcarranzan/quarkus-reproducer.git
  2. Execute mvn clean verify
  3. Output:
    Response body doesn't match expectation.
    Expected: is "Headers response: Hello RESTEasy"
    Actual: Hello RESTEasy

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus version or git rev

No response

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

No response

Additional information

No response

geoand commented 2 months ago

cc @jamezp

jedla97 commented 1 month ago

Note: I was working where @jcarranzan left and this bug seems really strange. I update his reproducer to resource class looking like this:

@Path("/hello")
public class GreetingResource {
    @GET
    @Path("/any")
    public String headers() {
        return "ok";
    }
    @GET
    @Path("/hello")
    @Produces(MediaType.TEXT_PLAIN)
    public String hello() {
        return "Hello RESTEasy";
    }
}

and in attached test only path from /hello to /hello/hello was changed

So to fix his reproducer is enough to add one endpoint.

Additional findings: In addition when both of these endpoints are anotated with @Produces(MediaType.TEXT_PLAIN) it start failing again.