-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Error in RestTemplate when setting the same HTTP header through ClientHttpRequestInterceptor and HttpEntity [SPR-15066] #19632
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
Comments
Einar Pehrson [Atlassian] commented Sébastien, thanks for triaging this issue. I couldn't assign it to myself, but I'm in the process of submitting a patch to fix this bug. |
Sébastien Deleuze commented You're welcome. That said, I am not sure this is bug. The Javadoc explains you need to wrap the request in a Any thoughts? |
Einar Pehrson [Atlassian] commented That crossed my mind, but I interpreted "Optionally wrap the request to filter HTTP attributes." as the wrapping being optional, since you can add additional HTTP headers without wrapping the request. More importantly though, |
Sébastien Deleuze commented Ok thanks for the PR. Arjen Poutsma Could we have your feedback on this issue and the related PR? |
HerrDerb commented Are there already any updates for this issue? I just ran into the same |
Sébastien Deleuze commented After a deeper look, I agree that this half mutable Arjen Poutsma Can you please check that you are ok with the proposed changes? |
Einar Pehrson [Atlassian] commented Sébastien, I see you've made use of part of my PR from a year ago. But the parts you left out fixed this bug for requests that have a body. Was that on purpose? I realize I only added a unit test for requests without a body. |
Sébastien Deleuze commented Good point, I will fix that and add another test for that use case. |
Sébastien Deleuze commented Done |
Einar Pehrson [Atlassian] commented Sébastien, I see that you have now incorporated all the changes from my PR 1277 in your commits 554662e and 73a81f9. I have closed that PR, but could you please tell me what I should do differently to have my PR approved and merged, if I were to attempt to contribute to Spring Framework another time? Since there was never any feedback on my PR, I simply forgot about it until HerrDerb commented last week. |
Sébastien Deleuze commented Einar Pehrson [Atlassian] No you did the right thing, this time I changed the implementation too much to reuse it directly. Thanks again for your contribution! |
Einar Pehrson [Atlassian] opened SPR-15066 and commented
When using
HttpEntity
to make a request withRestTemplate
, theHttpHeaders
passed toClientHttpRequestInterceptor
s is mutable but with immutable values.Steps to Reproduce
RestTemplate
with aClientHttpRequestInterceptor
that adds a value for a particular headerHttpEntity
with anHttpHeaders
containing a different value for that same headerRestTemplate
methods that accepts anHttpEntity
Actual Results
An
UnsupportedOperationException
is thrown.Expected Results
The request is sent with both values for the header.
Affects: 4.3.5
Reference URL: #1277
Backported to: 4.3.14
The text was updated successfully, but these errors were encountered: