I have 2 endpoints in Jersey configured for the same URL, but each one generates a different type of data (JSON or CSV).
When a request comes with the header Accept: application/json
I see getDataJson
is invoked, and when it comes with Accept: text/csv
I see getDataCsv
is invoked.
Nonetheless, when a request comes with Accept: */*
, I expected one of the methods to be invoked consistently (getDataJson
if it's the first one) but instead, I have a server where Accept: */*
always causes getDataCsv
to be invoked, and another server where getDataJson
is always the one invoked.
Do you know what could be the reason Jersey's behaviour is not consistent?
@POST
@Path("customer/{custId}/search/stuff")
@Consumes(MediaType.APPLICATION_JSON)
@Produces({MediaType.APPLICATION_JSON})
MyDataResponse getDataJson(@PathParam("custId") UUID custId,
SearchParams params);
@POST
@Path("customer/{custId}/search/stuff")
@Consumes(MediaType.APPLICATION_JSON)
@Produces("text/csv")
Response getDataCsv(@PathParam("custId") UUID custId,
SearchParams params);
More info:
- I'm using Jersey 2.33
- I already ran
sha256sum
on the jars of my app thinking maybe there was a difference, but they are identical. - I found some docs here, but the section
Procedure 8.2. MessageBodyReader<T> Selection Algorithm
didn't give me the info I wanted