Skip to content

Disable streaming when reading to Resources in RestTemplate [SPR-14882] #19448

Closed
@spring-projects-issues

Description

@spring-projects-issues

Hadrien Kohl opened SPR-14882 and commented

This issue has been updated to reflect the actual outcome of the discussion. See next section and comments for the original report.

The ResourceHttpMessageConverter supports converting from an HttpInputMessage to an InputStreamResource. This is valid when reading resources on the server side, but it's not compatible with the way RestTemplate works.

The API exposed by RestOperations imply that the HTTP server response should be fully consumed and properly closed by the time the exchange method returns. In other words, this HTTP client does not support streaming the HTTP response.

The current arrangement allows reading InputStreamResource with RestTemplate, which should not be possible.

Original report:

InputStreamResource are closed by SimpleClientHttpResponse

The http stream wrapped by InputStreamResource is closed by SimpleClientHttpResponse, rendering it unusable.

#1017 (comment)

I'll make a PR with a test.


Affects: 4.3.3

Reference URL: #18612

Issue Links:

Referenced from: commits afd93a0

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions