Does RestTemplate automatically release connection?

百般思念 提交于 2021-02-09 12:52:17

问题


I am shifting my REST client module from HttpClient.executeMethod(method) to RestTemplate.postForLocation(uri, obj). With the HttpClient, I would explicitly release the connection of the method:

deleteMethod.releaseConnection();

I cannot find anything equivalent within the Spring RestTemplate. Does it automatically release connections? Another way to ask would be, I suppose, is it safe to not do anything after calling the RestTemplate.postForLocation?


回答1:


One of the goals of spring templates is to make easy the things that are redundant. RestTemplate is not the exception and it manage the connection for you.

You can see more here.

http://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/client/RestTemplate.html



来源:https://stackoverflow.com/questions/39795236/does-resttemplate-automatically-release-connection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!