Is a Jersey Client WebTarget thread-safe?

Viewed 2790

Is a Jersey Client WebTarget created as following thread-safe?

WebTarget client = ClientBuilder
        .newClient(new ClientConfig(new JacksonJaxbJsonProvider(<object mapper Jackson>, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS)))
        .target("<url>");

Note that the Jackson ObjectMapper must also be thread-safe for this.

1 Answers

The methods on a WebTarget that create request builders or new WebTargets are thread safe. The methods inherited from Configurable, that modify the ClientConfig may not be thread safe.

Jackson ObjectMapper is also thread safe.

So as long as you don't reconfigure the WebTarget after initialisation you should be good to go.

Related