Hello and a wonderful Sunday,

My team is currently on the migration path to JAX-RS. The goal is remove the 
Apache HTTP client and reduce the number of dependencies in our code base. 
While doing this we stumbled upon the question about thread safety and caching 
pars of the JAX-RS client stack. I hope the question is addressed to correct 
list.

Which components can be cached and reused in a thread safety way? According to 
[1] I came up with those rules:

1. javax.ws.rs.client.Client - only if the URI and headers are the same
2. javax.ws.rs.client.ClientBuilder - ???
3. javax.ws.rs.client.Invocation.Builder - ???

Would you be so kind and comment on this?

Currently we do no caching at all. On every invocation of our internal clients 
we create a new builder, new ClientBuilder, new WebTarget, new Invocation. 

Additionally we did some benchmarks while doing the refactoring and it does not 
seem to harm the performance that we do not cache anything. Nevertheless I 
would appreciate an answer from the experts.

Best Karl

[1] 
http://cxf.apache.org/docs/jax-rs-client-api.html#JAX-RSClientAPI-ThreadSafety

Reply via email to