-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Make hasEntity() work with a closed stream. #138
Conversation
|
Can one of the admins verify this patch? |
|
Jenkins, please test this patch. |
|
Hi Dan, Before we can review your pull request, we need you to sign Oracle Contributor Agreement. It usually takes some time until the OCA is officially approved and listed on the page linked above (which is a relevant list for us). Also, every pull request should have a issue opened in our bugtracker. It is a good practice to place mutually links from github to JIRA and vice versa. More information about contributing to Jersey: https://jersey.java.net/scm.html#/Submitting_Patches_and_Contribute_Code Thanks, |
|
In the process of getting the OCA submitted, will update when that's done. |
|
Ok, OCA is in (Daniel Downs) and issue https://java.net/jira/browse/JERSEY-2843 has been created. Sorry for the delay on that. |
Make hasEntity() work with a closed stream.
|
Merged, thanks for your contribution and this time sorry for the delay on our side. Regards, |
|
Thanks! |
|
Hi @dadowns, sorry to inform you but this change has to be reverted – it's against the JAX-RS specification. See Javadoc to Response#hasEntity(). Michal |
|
If that's the case then why have a try catch that explicitly catches the IllegalStateException and returns false? If that's the spec then.... ok, but not having any "safe" way to check if there's an entity seems broken in that every call to hasEntity must be wrapped in the same try catch that's inside hasEntity. Since the spec wants a IllegalStateException then the whole method can just be: return !entityContent.isEmpty(); as internally it'll throw the exception when the connection is closed. |
|
Yeah, you're right about the simplification. Will look at it. If you're not satisfied with what the spec offers, feel free to file an improvement request here. Thank you! |
InboundMessageContext.hasEntity() currently throws an IllegalStateException outside the try catch due to the extra call to entityContent.ensureNotClosed() if the entity stream is already closed.
This check is not needed here due to EntityInputStream.isEmpty() calling ensureNotClosed() internally.