-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify when to invoke MBR and MBW pipeline #711
Comments
Sorry for the delayed response. Not invoking the MBW pipeline if there is no response entity sounds reasonable to me. Especially because the responsible MBW can only be determined if you have an entity class. I'm +1 for making this more explicit by mentioning it in the MBW API docs. The MBR case is more difficult. For the MBR one could decide whether to invoke the pipeline either by the presence of a request body sent by the client OR by the presence of an entity parameter (or Other thoughts? |
Hi @chkal,
In the case where a request body is sent by the client and there is no entityParemeter (or
So according to me MBR, should only be invoked in this case. I mean when user explicitly express that he cares about the request body by adding entity parameter or Which uses cases are you thinkng about ? |
Agreed. Actually the JAX-RS implementation knows if the matched resource method declares an entity parameter or if there is any
IMO it would make sense to invoke the MBR even if there is no request body, because a |
I get you point. But in the case where I'm not interested in "creating" entity stream when there is no request body, the MBR will be invoked and will just add "extra treament" for nothing right ? IMO the best option for user to "create" entity stream when there is no request body is to do it from the filter chain using "ContainerRequestContext.setEntityStream()". Then the MBR will be invoked after that normally with something to process. WDYT ? |
Correct.
Agreed. This would certainly be a better option. I just wanted to mention that in theory people could use the @eclipse-ee4j/eclipse-jaxrs Any other thoughts? |
I think a MBR should be called if there is an entity param (or If there isn't an entity param, then I would understand why calling a MBR does not make much sense. I understand that this behavior is different for requests and responses, but that asymmetry is inherent to a client-server architecture and the reason why we have different types of filters, different APIs, etc. |
As I was saying to @chkal, I understand this point of giving a chance to user to produce one. So in order not to pay this extra cost for nothing, the best solution will be to let user to create/modify entity at filtering step, since this step will always be invoked whether there is a request entity or not. And then if the entity exists invoke MBR as expected. WDYT ? Do you see any case where entity creation should/could not be done at filtering step and sould only be done in MBR ? |
@NicoNes I don't believe the two cases are equivalent. MBRs and their interceptors are typed while filters operate on byte streams: providing a default would be a lot easier using the MBR/interceptor chain. |
@spericas Yes for sure it's more academic than practical I agree. |
@NicoNes Yes, we can certainly do that. If you have a suggestion as how/where to do this based on your analysis, please provide it here. We can target this for 2.2. |
I was thinking about simply adding some statements like this to the MBW/MBR API docs:
|
@chkal LGTM |
I was looking at the Http RFCs trying to see if there is something preventing us from handling request body depending on the HTTP method we are using. Then if we all agree about that, @chkal statements looks good to me 👍 |
I don't think that this should be enforced on our side. BTW: I just open #744 for adjusting the MBW/MBR API docs. Please let me know what you think. |
I agree with @chkal. No need to enforce that. |
Clarify in which situations MBW/MBR pipelines are executed (#711)
@spericas PR is merged. Can we close this issue? |
Shall be backport this clarification into 2.1.x? |
@mkarg +1 for closing. And IMO we could backport it. |
@mkarg Yes on closing and backporting. |
Ok, so I put it on my backport stack. |
Hi guys,
AFAIK the current spec does not clearly state when to invoke MBR and MBW pipeline and this leads to situation like following:
Consider the given resource and providers below registered in a JAX-RS application:
When calling the GET method of
TestResource
from my browser without sending no request body I wasnot expecting the
TestReaderInterceptor.aroundReadFrom()
neitherTestMBR.readFrom()
to be invoked, but they are although there is no request body to process.In contrast on the response side, the MBW pipeline is not invoked when there is no response body.
This behavior is the same whatever you are doing a GET, POST, PUT. I did it in both the RI and RESTEASY
So what I suggest is to clearly state that both MBR and MBW pipeline MUST be invoked only when there is a request/response body to process.
In other words when no entity is identified in previous filter chain step, containerRequestContext.hasEntity()/containerResponseContext.hasEntity() returns false, MBR/MBW MUST not be invoked.
WDYT? Do you think it is acceptable ?
This PR follows up dicussion started here #659 (comment)
The text was updated successfully, but these errors were encountered: