May 29th, 2012, 05:59 AM
Bug in Spring 3.1.1 RestTemplate Class in retrieving response Buffer on 401 error
I have a RESTful web server implemented with custom authentication and returns 401 plus a JSON response when authentication fails. When the authentication fails as on a GET, all is well and RestTemplate returns back both the status code as well as the JSON response but when we send a POST, the body gets lost. We see that an HttpRetryException is getting called when attempting to retrieve the responseBody. This is in function getResponseBody in DefaultResponseErrorHandler. I assume this means that the response is already retrieved at an earlier point and therefore gets lost.
May 29th, 2012, 06:25 AM
The reason for the difference between GET and PUT is the field doOutput. In the case of the POST it is set to true so the output is read in earlier, in the executeInternal function (SimpleBufferingClientHttpRequest). So, i am not sure what the fix is but i am definitely sure that it is not intended behavior here
Jun 3rd, 2012, 02:42 PM
Is the proper protocol to open a JIRA for this issue?
Nov 16th, 2012, 09:49 AM
Hi, I can confirm that the same issue is in spring framework 3.1.2 release. A JIRA ticket is created to track the issue: