Springcloud config using the auto-refresh function will inevitably step on some of the pit, let's introduce
often need to dynamically generate configuration refresh, you only need to increase @RefreshScope, and perform a manual refresh link / actuator / refresh, or integrated springcloudbus automatically refresh, but some need to be instantiated dynamic configuration during refresh some of the spring inside the complex object, there will not be automatically updated, for example zuul.
zuul routing configuration can be automatically refreshed,
zuul:
sensitive-headers:
routes:
api-b:
path: /apib/**
serviceId: dataeyeServer
But the interior design to the zuul resttemplate some timeout configuration, if a change, and manually refresh error Connection pool shut down appears on the title of "zuul.host. *" Property change
zuul:
host:
connect-timeout-millis: 10000
socket-timeout-millis: 600000
The following error message:
java.lang.IllegalStateException: Connection pool shut down
at org.apache.http.util.Asserts.check(Asserts.java:34) ~[httpcore-4.4.8.jar:4.4.8]
at org.apache.http.pool.AbstractConnPool.lease(AbstractConnPool.java:191) ~[httpcore-4.4.8.jar:4.4.8]
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.requestConnection(PoolingHttpClientConnectionManager.java:257) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:176) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) ~[httpclient-4.5.3.jar:4.5.3]
at org.springframework.http.client.HttpComponentsClientHttpRequest.executeInternal(HttpComponentsClientHttpRequest.java:89) ~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48) ~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53) ~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:659) ~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:628) ~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:302) ~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]
This is due to the auto refresh, due to host the Super time configuration change causes the connection pool to close, and then re-create the ready, but did not re-create the connection pool created in the process to reproduce or quote the original connection pool lead to error.
Solution one: Upgrade springcloud to Edgware.RELEASE, namely
the upgrade version springcloud-commons-dependencies to 1.3.2.RELEASE
Solution two: manually instantiate connection pool
References
https://github.com/spring-cloud/spring-cloud-netflix/issues/3406
https://github.com/spring-cloud/spring-cloud-commons/issues/330
https://github.com/spring-cloud/spring-cloud-config/issues/918