Skip to content

Do not close response for InputStreamResource #27194

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

Closed
wants to merge 1 commit into from

Conversation

quaff
Copy link
Contributor

@quaff quaff commented Jul 21, 2021

Closing underlying stream should be responsibility of InputStreamResource

ResponseEntity<InputStreamResource> entity = restTemplate.getForEntity(url, InputStreamResource.class);
try (InputStream is = response.getBody().getInputStream()) {
	// do something
}

"java.io.IOException: closed" is fixed after this commit

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jul 21, 2021
@quaff quaff marked this pull request as draft July 21, 2021 06:21
Closing underlying stream should be responsibility of InputStreamResource

ResponseEntity<InputStreamResource> entity = restTemplate.getForEntity(url, InputStreamResource.class);
try (InputStream is = response.getBody().getInputStream()) {
	// do something
}

"java.io.IOException: closed" is fixed after this commit
@quaff quaff marked this pull request as ready for review July 21, 2021 06:46
@bclozel
Copy link
Member

bclozel commented Jul 21, 2021

RestTemplate is closing the response by design.
See #21424 and #19448 (comment) for more background about this. I'm declining this PR as a result.

Thanks!

@bclozel bclozel closed this Jul 21, 2021
@bclozel bclozel added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jul 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants