You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RestTemplate's connection/read timeout settings not applied when using Apache HttpClient [SPR-11442] #16068
are not working since Spring 4.0.0. (affected versions are: 4.0 GA, 4.0.1, 4.0.2 and current master)
The version of Apache HttpClient used is 4.3.2 (the latest as of now - Spring 4 requires HttpClient 4.3+)
Actually, the timeout is overwritten to zero on execution, and therefore it might cause an unexpected hang.
In the old version of spring (e.g. 3.2.x) everything works fine. (see the test in the reference URL)
More details I've figured out:
HttpComponentsClientHttpRequest is created well with the timeout settings configured.
(The configuration is hold in an instance of RequestConfig, contained in a HttpContext)
But when the request it is executed, RequestConfig is overwritten completely.
(see the line 806 of AbstractHttpClient.java of HttpClient 4.3)
Sorry, there was a little mistake. Thanks for pointing out it.
I've updated the gist to revision 3, making the HCCHRF being passed into RestTemplate. The test still passes as you mentioned, but the problematic situation is: injecting an explicitly created instance of DefaultHttpClient into the HCCHRF. Then the test fails (passes in 3.2.x however).
Since DefaultHttpClient is deprecated as of 4.2, using HttpClientBuilder (introduced in 4.3+) did not cause the problem. Although Spring 4.x depends on HttpClient 4.3+, I feel that the deprecated API could be supported also, to ensure compatibilities with third-party (spring-dependent) modules.
Activity
spring-projects-issues commentedon Feb 26, 2014
Alex Adeyemo commented
I don't think this is a bug.
The reporter didn't pass HttpComponentsClientHttpRequestFactory to the resttemplate.
Check the gist posted https://gist.github.com/wookayin/9087154
spring-projects-issues commentedon Feb 26, 2014
Juergen Hoeller commented
Indeed, the test passes once the HttpComponentsClientHttpRequestFactory is actually passed into RestTemplate.
I'm marking this as 'invalid' for the time being; to be reopened if any issues remain.
Juergen
spring-projects-issues commentedon Feb 28, 2014
Jongwook Choi commented
Sorry, there was a little mistake. Thanks for pointing out it.
I've updated the gist to revision 3, making the HCCHRF being passed into RestTemplate. The test still passes as you mentioned, but the problematic situation is: injecting an explicitly created instance of DefaultHttpClient into the HCCHRF. Then the test fails (passes in 3.2.x however).
Since DefaultHttpClient is deprecated as of 4.2, using HttpClientBuilder (introduced in 4.3+) did not cause the problem. Although Spring 4.x depends on HttpClient 4.3+, I feel that the deprecated API could be supported also, to ensure compatibilities with third-party (spring-dependent) modules.
Thanks.
Jongwook Choi
spring-projects-issues commentedon Feb 28, 2014
Juergen Hoeller commented
Thanks for the update. I'll have a look at that specific case; looks like we could be more careful with out RequestConfig overriding there.
Juergen
spring-projects-issues commentedon Mar 4, 2014
Stéphane Nicoll commented
Juergen Hoeller, I have a PR available with a candidate implementation. Could you please review it? Thanks!
spring-projects-issues commentedon Mar 10, 2014
Juergen Hoeller commented
Stéphane, this looks alright to me. Please go ahead and merge it into master...
Juergen
spring-projects-issues commentedon Mar 10, 2014
Stéphane Nicoll commented
This has been merged to master.