Replies: 7 comments 24 replies
-
I will see if I can create a reproducer for this. Thank you for reporting this @t1 |
Beta Was this translation helpful? Give feedback.
-
I'm not sure I follow this. I don't see a |
Beta Was this translation helpful? Give feedback.
-
Hey @jamezp, Well I think @t1 also already proposed to fix MBW
We all agree this failure is coming from:
But as I said before according to my understanding of the spec:
So I still think that this point shoudl be implemented as I described it previously (see below). Why does it seems wrong to you ?
-- Nicolas |
Beta Was this translation helpful? Give feedback.
-
I also just re-read the algorithms and your comments and I was wrong on several occasions. But I think, once you found it, the solution is actually rather simple: let me point you again to step 2. of the inner algorithm for Determining the MediaType of Responses. As we assume that there is no In step 8., it says: "If 𝑚 is a concrete type, set 𝑀selected=𝑚, finish." Assuming there is no other MBW that can produce something with a higher priority, the selected media type must be The outer algorithm for the Message Body Writer seems to be implemented correctly. And I was wrong to suggest to change the writer. I understand (now) that it actually must not handle For, e.g., a If we all agree on this, I could provide an additional pair of eyes to look into the code. I think a config parameter should really only be our last option. |
Beta Was this translation helpful? Give feedback.
-
One concern I have with these changes is there are 18 test failures.
I've not looked at each one yet, but I never like changing tests for bug fixes if possible :) |
Beta Was this translation helpful? Give feedback.
-
I've filed https://issues.redhat.com/browse/RESTEASY-3538 for this. I think it's going to take a little time to do as I think we might need to do a fairly large refactor to get this right. The current changes I've got in my testing branch are not correct. |
Beta Was this translation helpful? Give feedback.
-
Here is the initial look at the changes, #4302. It's not at all complete as there are a bunch of TODO's I need to address and documentation needs to be updated. However, I wanted to get some eyes on it. |
Beta Was this translation helpful? Give feedback.
-
I'm working mostly on WildFly (actually all the way back to since JBoss 4.0.2; currently 31.0.1). I generally let my JAX-RS services directly return instances of my own domain type, e.g.
Product
. If one of my clients doesn't specify whichContent-Type
they are ready toAccept
, they get a500 Internal Server Error
. IIUC, this is because RestEasy determines that it should return anapplication/octet-stream
, but there is noMessageBodyWriter
that could produce that from my domain type (only forbyte[]
, etc.).I see many people work around this by annotating all of their resource methods with
@Produces(APPLICATION_JSON)
. But IIUC, this mechanism was originally intended for when you have multiple methods for the same path returning aString
(et.al.). The@Produces
annotation can then be used to pick the method matching best to theAccept
header sent by the client. This is not only extra work, it also would prevent using a newMessageBodyWriter
for a newContent-Type
, e.g.application/yaml
.For a long time, I had assumed this to be the result of the spec defining
application/octet-stream
to be the fallback. But I just found out in an JAX-RS issue, that the specified algorithm is not implemented correctly in RestEasy: AsJsonBindingProvider
(andResteasyJackson2Provider
, andJAXBXmlRootElementProvider
, and probably some more) can produce a JSON (et.al.) from myProduct
. So the set of potential producersP
found in step 2 should contain them all. The set of acceptable content typesA
determined in step 4 has to be*/*
. Then step 8 should match and one of those types (preferablyapplication/json
) should be picked; step 9 should never be reached.I assume that the corresponding issue exists on the
@Consumes
side.I would very much appreciate it if this could be fixed and make my life easier. Thanks!
P.S.: I still wonder why this is not part of the TCK.
Beta Was this translation helpful? Give feedback.
All reactions