Is a Jersey Client WebTarget thread-safe?

Dave Teezo :

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.

Gerrit :

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.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=466693&siteId=1