File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change 28
28
import org .springframework .web .client .RestTemplate ;
29
29
30
30
import java .io .UnsupportedEncodingException ;
31
+ import java .util .concurrent .TimeUnit ;
31
32
32
33
@ Component
33
34
public class RestTemplateFactory implements FactoryBean <RestTemplate >, InitializingBean {
@@ -58,7 +59,9 @@ public boolean isSingleton() {
58
59
}
59
60
60
61
public void afterPropertiesSet () throws UnsupportedEncodingException {
61
- CloseableHttpClient httpClient = HttpClientBuilder .create ().build ();
62
+ CloseableHttpClient httpClient = HttpClientBuilder .create ()
63
+ .setConnectionTimeToLive (portalConfig .connectionTimeToLive (), TimeUnit .MILLISECONDS )
64
+ .build ();
62
65
63
66
restTemplate = new RestTemplate (httpMessageConverters .getConverters ());
64
67
HttpComponentsClientHttpRequestFactory requestFactory =
Original file line number Diff line number Diff line change @@ -169,6 +169,10 @@ public int readTimeout() {
169
169
return getIntProperty ("api.readTimeout" , 10000 );
170
170
}
171
171
172
+ public int connectionTimeToLive () {
173
+ return getIntProperty ("api.connectionTimeToLive" , -1 );
174
+ }
175
+
172
176
public List <Organization > organizations () {
173
177
174
178
String organizations = getValue ("organizations" );
You can’t perform that action at this time.
0 commit comments