Using Spring 4.3.12.RELEASE (provided by Spring Boot 1.5.18), I came across an issue that after heavy network instabilities, instead of timing out after some time (triggering my retry behaviour), my threads would all get stuck indefinitely with the following thread dump:
"pool-128-thread-5" #34046 prio=5 os_prio=0 tid=0x00007fe37c3cf590 nid=0x13cd waiting on condition [0x00007fe3458cd000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000ac08fd30> (a org.springframework.util.concurrent.SettableListenableFuture$SettableTask)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
at java.util.concurrent.FutureTask.awaitDone(FutureTask.java:429)
at java.util.concurrent.FutureTask.get(FutureTask.java:191)
at org.springframework.util.concurrent.SettableListenableFuture.get(SettableListenableFuture.java:112)
at org.springframework.http.client.Netty4ClientHttpRequest.execute(Netty4ClientHttpRequest.java:86)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:660)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:636)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:610)
[...]
I am using the Netty4ClientHttpRequestFactory
(together with Netty 4.1.36.Final) for my RestTemplate
:
@Bean
public RestTemplate restTemplate() throws SSLException {
final SslContext context = SslContextBuilder.forClient()
.trustManager(InsecureTrustManagerFactory.INSTANCE)
.build();
final Netty4ClientHttpRequestFactory factory = new Netty4ClientHttpRequestFactory();
factory.setConnectTimeout(CONNECT_TIMEOUT_MILLIS); // Value is > 0
factory.setReadTimeout(READ_TIMEOUT_MILLIS); // Value is > 0
factory.setSslContext(context);
return new RestTemplate(factory);
}
Any thoughts on this?
Comment From: bclozel
Netty4ClientHttpRequestFactory
has been deprecated in 5.0 and removed in 6.0. We don't plan on addressing improvements there. This issue hasn't seen much activity since, so I'm suspecting this problem has been solved in the meantime at the Netty level.