Spring RestTemplate - Need to release connection?

前端 未结 3 1529
情深已故
情深已故 2021-02-05 20:44

This is my Configuration for Rest Template,

    @Bean
    @Qualifier(\"myRestService\")
    public RestTemplate createRestTemplate(@Value(\"${connection.timeout}         


        
3条回答
  •  独厮守ぢ
    2021-02-05 21:24

    I think the answer is here: org.springframework.remoting.httpinvoker.HttpComponentsHttpInvokerRequestExecutor#doExecuteRequest

        @Override
        protected RemoteInvocationResult doExecuteRequest(
                HttpInvokerClientConfiguration config, ByteArrayOutputStream baos)
                throws IOException, ClassNotFoundException {
    
            HttpPost postMethod = createHttpPost(config);
            setRequestBody(config, postMethod, baos);
            try {
                HttpResponse response = executeHttpPost(config, getHttpClient(), postMethod);
                validateResponse(config, response);
                InputStream responseBody = getResponseBody(config, response);
                return readRemoteInvocationResult(responseBody, config.getCodebaseUrl());
            }
            finally {
                postMethod.releaseConnection();
            }
        }
    

提交回复
热议问题