The example use springboot 3.0 is normal, but use springboot 3.3 have exception. Maybe it is different from #31902
detail error: org.springframework.web.client.ResourceAccessException: I/O error on POST request for "https://someurl/api/": insufficient data written at org.springframework.web.client.RestTemplate.createResourceAccessException(RestTemplate.java:915) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:895) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:830) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:691)
Comment From: automvc
try {
URI uri = getUri(request, method);
HttpHeaders headers = new HttpHeaders();
Enumeration<String> headerNames = request.getHeaderNames();
//set head from request
HttpEntity httpEntity = new HttpEntity<>(body, headers);
ClientHttpRequestFactory clientHttpRequestFactory = (new SimpleClientHttpRequestFactory() {
//...
});
ClientHttpRequestFactory factory = new BufferingClientHttpRequestFactory(clientHttpRequestFactory); // already use BufferingClientHttpRequestFactory
RestTemplate restTemplate = new RestTemplate(factory);
ResponseEntity serverResponse = null;
serverResponse = restTemplate.exchange(uri, method, httpEntity, String.class); //this line have ResourceAccessException : insufficient data written
// ... other
} catch (Exception e) {
logger.error("", e);
}
return ResponseEntity.badRequest().build();
Comment From: poutsma
If you'd like us to spend some time investigating, please take the time to provide a complete minimal sample (something that we can unzip or git clone, build, and deploy) that reproduces the problem.
Comment From: snicoll
@automvc please stop creating duplicate issues. Can you provide the sample that we requested?
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.
Comment From: rajukosna
Sample code is like:
@Autowired RestTemplate restTemplate;
try { URI uri = getUri(request, method);
HttpHeaders headers = new HttpHeaders();
Enumeration<String> headerNames = request.getHeaderNames();
//set head from request
HttpEntity httpEntity = new HttpEntity<>(body, headers);
ResponseEntity serverResponse = null;
serverResponse = restTemplate.exchange(uri, method, httpEntity, String.class); //this line have ResourceAccessException : insufficient data written
// ... other
} catch (Exception e) {
logger.error("", e);
}