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

Provide an memory efficient alternative to ClientHttpRequestInterceptor #22002

Closed
spring-projects-issues opened this issue Nov 5, 2018 · 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

Phil Webb opened SPR-17470 and commented

See this issue for some background.

Currently the BasicAuthenticationInterceptor class is a ClientHttpRequestInterceptor which causes the entire body to be read into a byte array and can cause OutOfMemoryError errors. I've managed to work around the issue by using a AbstractClientHttpRequestFactoryWrapper, but it would be really nice if there was a better way to do this. Perhaps we can create an alternative ClientHttpRequestInterceptor that can be used when only headers need to be changed.


Reference URL: spring-io/artifactory-resource#27

@spring-projects-issues spring-projects-issues added status: waiting-for-triage An issue we've not yet triaged or decided on type: enhancement A general enhancement in: web Issues in web modules (web, webmvc, webflux, websocket) and removed type: enhancement A general enhancement labels Jan 11, 2019
@poutsma
Copy link
Contributor

poutsma commented Jan 23, 2019

This would require a major overhaul of the interception mechanism, while we are winding down our development effort of RestTemplate in favour of WebClient.

I suggest closing as declined. What do you think, @rstoyanchev ?

@rstoyanchev
Copy link
Contributor

Yes I agree, and it helps that there is a workaround.

@rstoyanchev rstoyanchev 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 Jan 23, 2019
@philwebb philwebb changed the title BasicAuthenticationInterceptor can cause OutOfMemoryError [SPR-17470] Provide an memory efficient alternative to ClientHttpRequestInterceptor Sep 10, 2019
@philwebb philwebb reopened this Sep 10, 2019
@philwebb philwebb added status: waiting-for-triage An issue we've not yet triaged or decided on and removed status: declined A suggestion or change that we don't feel we should currently apply labels Sep 10, 2019
philwebb added a commit to philwebb/spring-framework that referenced this issue Sep 10, 2019
Add `ClientHttpRequestInitializer` interface that can be used with any
`HttpAccessor` to initialize each `ClientHttpRequest` before it's used.

This provides a useful alternative to `ClientHttpRequestInterceptor`
when users need to configure things like `HttpHeaders`.

Closes spring-projectsgh-22002
@philwebb
Copy link
Member

Unfortunately the workaround that I suggested cannot work with MockRestServiceServer which is causing us issues in Spring Boot (see spring-projects/spring-boot#17885).

I have a relatively small enhancement to HttpAccessor that add an initialization callback. I've pushed it to https://github.com/philwebb/spring-framework/tree/gh-22002 for review.

I know it's quite late in the day to be asking for this, but could it be considered for 5.2? I can't really find any good solution using the existing interceptor mechanism that works in all situations.

@rstoyanchev
Copy link
Contributor

Looks good to me. Straight forward enough for 5.2.

@rstoyanchev rstoyanchev added this to the 5.2 GA milestone Sep 10, 2019
@rstoyanchev rstoyanchev added type: enhancement A general enhancement and removed for: team-attention status: waiting-for-triage An issue we've not yet triaged or decided on labels Sep 10, 2019
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

4 participants