Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restTemplate.exchange have exception "insufficient data written" with springboot 3.3 #41088

Closed
automvc opened this issue Jun 12, 2024 · 1 comment
Labels
for: external-project For an external project and not something we can fix status: duplicate A duplicate of another issue

Comments

@automvc
Copy link

automvc commented Jun 12, 2024

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();
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 12, 2024
@bclozel
Copy link
Member

bclozel commented Jun 12, 2024

Duplicates spring-projects/spring-framework#33015

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Jun 12, 2024
@bclozel bclozel added status: duplicate A duplicate of another issue for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants