Hi John,
On 30/10/2013 1:21 PM, John Zajac wrote:
>
> In a nutshell, what are they?
>
> The 2.x api doc and user guide seem to be silent on the topic.
> Specifically, I want be able invoke other Restful services from the
> implementation of another (i.e. from multiple threads) in an efficient
> manner without unnecessarily regenerating client or targets etc. but
> of course safely . Googling so far has yielded some advice and
> comments, mostly for Jersey 1.x, but nothing official for 2.x and not
> something that is necessarily going to remain true over time for
> future releases of Jersey.
>
> I have started looking at the source to determine what can be
> considered thread safe (e.g. maybe the client), or whether it I need
> to use a pool for 'serial' re-use), and what must be created for each
> request (e.g. the builder returned by WebTarget.request(String).
> However, would like some to see what behavior can be depended on
> across releases.
>
> It would be nice if the jersey user guide could be updated with
> something along the lines of how jaxb addresses the subject
> (https://jaxb.java.net/guide/Performance_and_thread_safety.html).
>
> Anyone been down this road already?
>
I checked quickly a few months ago and Client, WebTarget looked
like they were thread-safe, but the unit tests (JerseyTest class in
particular) are not.
I would prefer thread-safety notes be added to individual class
Javadoc or using @ThreadSafe annotations (assume a class is not
thread-safe unless it says otherwise) as opposed to pooling the
discussion into an external document.
Gili