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)

example code:

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: bclozel

Duplicates https://github.com/spring-projects/spring-framework/issues/33015

Comment From: rajukosna

Hi . I am getting the bellow error using springboot3.3 and java 17. ERROR: insufficient data written : I/O error on POST request for http://some.com

Comment From: rajukosna

please help on this

Comment From: rajukosna

insufficient data written : I/O error on POST request for http://some.com/ this error is coming in using RestTemplate in springboot3.3 version

Comment From: bclozel

@rajukosna we never got the sample we requested. If you can reproduce the problem with a minimal sample application (something we can git clone or unzip) please create a new issue here: https://github.com/spring-projects/spring-framework/issues

Note: if you cannot reproduce the problem with a minimal sample application this is likely to be a problem specific to your application. In this case please ask a question on StackOverflow.

Comment From: rajukosna

@bclozel Thank you for your quick response

Comment From: rajukosna

@bclozel Example code:

ResponseEntity<ResponseDTO> responseEntity = null;
        try {
            LOGGER.info(REST_CALL_FOR_URL);
            if (headers == null) {
                headers = new HttpHeaders();
            }
            headers.add(HEADER_NAME, getFullContextInJson());

            HttpEntity<?> httpEntity = new HttpEntity<>(body, headers);
            responseEntity = restTemplate.exchange(UriComponentsBuilder.fromHttpUrl(url).build(true).toUriString(), 
                    httpMethod, httpEntity, ResponseDTO.class);

            return responseEntity;
        } catch (RestClientException restClientException) {
            logger(restClientException);
            return new ResponseEntity<>(restClientException.getMessage(), HttpStatus.BAD_REQUEST);
        }

ERROR: insufficient data written : I/O error on POST request for \"http://localhost:8083/api/o......... ": insufficient data

Comment From: bclozel

Thanks for the code snippet but I can't reproduce this issue.

Comment From: rajukosna

Thanks you we are using spring boot 3.3.4 and java17 with this version I am getting this error.

Comment From: philwebb

@rajukosna We need a complete sample application to be able to help you. That way we know exactly what library versions you're using and how your application is configured. You should also upgrade to 3.3.7 or 3.4.1