-
Notifications
You must be signed in to change notification settings - Fork 113
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
Make request URI / UriInfo available in MessageBodyReader for client (and not just server) #796
Comments
I would really like
This would reduce the number of parameters in the methods and would give a solution to the original problem. You could implement some
and then retrieve it in your
|
While I agree that using something like |
The question is, why a server runtime injects |
Enlarging the number of injectable items would be nice. Do you think it would also be possible to inject |
@chkal If Jakarta EE specs are going to change their namespace/package, that will break backwards compatibility anyway. So, isn't it the perfect (and only) opportunity to fix some methods signatures and other things that couldn't have been fixed otherwise without breaking backwards compatibility? |
There is consensus among the committers to JAX-RS and among the Jakarta EE contributors at-large that the next release (Jakarta EE 9 / JAX-RS 2.2) should be backwards-compatible as best as possible (besides the package rename), and that intentionally breaking backwards compatibility to be deferred for a later release (e. g. Jakarta EE 10 / JAX-RS 3.x). |
tl;dr:
UriInfo
is not available in aMessageBodyReader
of a client implementation. Thus, I cannot get the request's URI to resolve relative URIs against.Long description: I am implementing a custom
MessageBodyReader
(for processing RDF) that needs to resolve URIs against the request URI during processing. If theMessageBodyReader
is used in a JAX-RS server implementation, which eg. processes incoming POST requests, I can obtain the request URI from aUriInfo
object that is injected at runtime using@Context
(as described eg. at https://stackoverflow.com/a/3314076):If the
MessageBodyReader
is called in a JAX-RS client implementation during the reading of anResponse
's entity, the injection does not happen, hence I get aNullPointerException
(see above for the line) when I write a client using JAX-RS like:My current workaround: Having read Chapter 10.4 "Filter and interceptor execution order" of the Jersey documentation, I found that in step 16, the
ClientResponseFilter
, I have access to both the request URI and the response headers. Hence I wrote aClientResponseFilter
that puts the request URI in a custom response header. Then, I can retrieve that custom header from the 5th parameter ofreadFrom(...)
.Full disclosure: A while ago, I posted this issue as a question on StackOverflow, but did not get much of a response apart from appreciation for my workaround. As I think there may be something fundamental behind it and I think server and client implementations should work analogously, I am filing my problem as an issue here now.
The text was updated successfully, but these errors were encountered: