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

Read large data using InputStreamResource at ResourceHttpMessageConverter [SPR-13443] #18023

Closed
spring-projects-issues opened this issue Sep 7, 2015 · 4 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Sep 7, 2015

Kazuki Shimizu opened SPR-13443 and commented

Currently,ResourceMessageConverter is reading as ByteArrayResource from the HTTP body. If large data has been set at http body, there is possibility that occur the OutOfMemoryError.

I want to be able to read as InputStreamResource as follows:

RestTemplate restTemplate = new RestTemplate();
Resource resource = restTemplate.getForObject("http://localhost:8080/myApp/foo.zip", InputStreamResource.class);

How do think ?
I submit a PR at the later.


Affects: 4.2.1

Issue Links:

Referenced from: pull request #871, and commits 1feb757

@spring-projects-issues
Copy link
Collaborator Author

Kazuki Shimizu commented

I've submit a PR.
Please check it.

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Good idea! Added in a slightly revised fashion now, also checking whether we support the specified resource class at all.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Kazuki Shimizu commented

Hi Juergen,

Thanks for polishing and merging!! i happy :)

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Feb 27, 2018

Mauro Molinari commented

But does this work as expected? Isn't the input stream already closed after the call to getForObject has ended?
See also #12015 and https://stackoverflow.com/a/48041200/1465635

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants