3

Spring RestTemplate timeout configuration example

By default, resttemplate uses timeout property from JDK installed on the machine which is always infinite in not overridden. To override the default JVM timeout, we can pass these properties during JVM start.

Or RestTemplate — default timeout value answer state that Spring RestTemplate has infinite timeout by default.

Is good practice to have infinite timeouts? Isn't it potential source of hidden problems? Shouldn't opinionated framework like Spring Boot set initial values for timeouts?

Justinas Jakavonis
  • 8,220
  • 10
  • 69
  • 114
  • Related: https://stackoverflow.com/a/52824223/2958086 implementations of HttpUrlConnection can override it. – Compass May 08 '19 at 19:56
  • Of course infinite timeout may be a little bit too much optimistic, but it is a default. Youself refer RestTemplate timeout configuration example, where you find a programatcally way to set this values with `SimpleClientHttpRequestFactory` Can not see your problem. – PeterMmm May 08 '19 at 19:58
  • I have overriden in my implementations. The question mainly is why Spring doesn't have initial values which would be lower. – Justinas Jakavonis May 08 '19 at 20:01

0 Answers0