Raedwald Raedwald - 1 year ago 670
Java Question

Is RestTemplate thread safe?

Is a Spring

RestTemplate
thread-safe? That is


  • Is a
    RestTemplate
    a Strategy object that multiple connections can safely share. or

  • Is a
    RestTemplate
    a connection object (like a data-base connection), which can not be shared while in use, and requires creation afresh, or pooling, for each connection.


Answer Source

RestTemplate is thread safe (emphasis added):

Conceptually, it is very similar to the JdbcTemplate, JmsTemplate, and the various other templates found in the Spring Framework and other portfolio projects. This means, for instance, that the RestTemplate is thread-safe once constructed