RestClient can not use both parameters, ClientHttpRequestFactory and ClientHttpRequestInterceptor #32773
Labels
for: stackoverflow
A question that's better suited to stackoverflow.com
in: web
Issues in web modules (web, webmvc, webflux, websocket)
status: invalid
An issue that we don't feel is valid
Affects: 6.1
I recently started migrating in a project from RestTemplate to RestClient. I used the RestClient builder as follows:
I then tried to continue, using the Rest client for uploading larger files (~300MB) as a FileInputStream to an online service like this:
Soon i realised, the RestClient is holding the whole file in memory, increasing the risk of OOMExceptions.
After a lot of debugging the wrong files, i stumbled accrosse the function: DefaultRestClient.createRequest(URI uri). I realised that it should not be allowed to specify both, RequestInterceptors and RequestFactories.
Hence first, the question why it is supported, although the defined RequestFactory will not be used and second, wouldn't it be more better to either disallow specifying both (following the fail fast principle) or at least documenting that a RequestFactory will not be used, if a RequestInterceptor is specified.
The text was updated successfully, but these errors were encountered: