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

RestTemplate adds duplicate accept header information #22320

Closed
wants to merge 2 commits into from

Conversation

geminiKim
Copy link

@geminiKim geminiKim commented Jan 29, 2019

Hi :)

In 4.3.x version, I found a bug that caused the Accept header to be duplicated.
I have added a validation test and fixed the bug, if you could review this PR then I appreciate it.

It seems to have been fixed in 5.0.x and above. It appears to be occurring in versions below 4.3.x.

If this PR is not in the correct format, please let me know. I will fix it.
Thank you.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 29, 2019
@jhoeller
Copy link
Contributor

jhoeller commented Feb 1, 2019

This got addressed for 5.1 through #21231. @bclozel, if we decide to backport a variant of that change, let's backport it to 5.0.13 as well as 4.3.23.

@bclozel bclozel changed the title Fix a bug for duplication of accept header RestTemplate adds duplicate accept header information Feb 11, 2019
@bclozel bclozel self-assigned this Feb 11, 2019
@bclozel bclozel added type: backport An issue that is a backport of another issue to a maintenance branch and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Feb 11, 2019
@bclozel bclozel added this to the 4.3.23 milestone Feb 11, 2019
bclozel pushed a commit that referenced this pull request Feb 11, 2019
Prior to this commit, the various `HttpMessageConverter` instances
configured for a given `RestTemplate` instance could all contribute
`MediaType` values to the "Accept:" request header.

This could lead to duplicate media types in that request header,
cluttering for the HTTP request for no reason.

This commit ensures that only distinct values are added to the request.

Issue: SPR-16690
Closes gh-22320
Closes gh-21231
@spring-projects-issues
Copy link
Collaborator

Fixed via 3e1b3c3

@jhoeller jhoeller added the type: bug A general bug label Feb 11, 2019
@bclozel
Copy link
Member

bclozel commented Feb 11, 2019

I've picked up your commits in a single change with 3e1b3c3.
I didn't backport the original fix since it was using java.util.stream.Stream and rewriting a lot of tests as a more general revision. The 5.0.x backport will be taken care of in #22401.

Thanks for your contribution!

@jhoeller jhoeller added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Feb 11, 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: backport An issue that is a backport of another issue to a maintenance branch type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants