-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Spring MVC @RequestHeader value is ignored [SPR-17617] #22149
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
Juergen Hoeller commented The Could you narrow the cause a bit further, possibly providing a test case for it? |
zsenyeg commented Hey,
I've made a small junit test about what i mean. Can you check the attached file pls? java version: 1.8 spring boot version: 2.1.0.RELEASE mockito-core version: 2.23.0
Cheers, zsenyeg [^RequestHeaderMethodArgumentResolverTest.java] |
The example doesn't help. The original description says the value attribute is filled out, the test uses a mock which does not do that. Please, provide an example with an actual annotated controller, or a snippet that shows what that declaration looks like. |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Hey, I just made a little runnable example, that fail as the previous unit test. The attached zip file contains a maven idea project, you can start it with the usual mvn spring-boot:run command. The sample rest service provides two get endpoints: Test both endpoints with the following http request header: Consent-ID with any value. cheers, |
Thanks for the sample. It looks like when Note that support for Spring MVC method parameter annotations on an interface was only added recently in 5.1 with #15682. |
@RequestHeader
value is ignored [SPR-17617]
@RequestHeader
value is ignored [SPR-17617]
I'll have to look into it before I can comment on that. |
At a glance, it appears that the infrastructure there is using |
I don't yet have a test in place, but I assume it's due to the fact that I'll add a test and fix it. 😉 |
OK. I see that So perhaps @jhoeller has indeed already fixed this. |
Yep, this was the fix: c58da71#diff-4e35372004bab14ceec2182f61179bafL497 Closing this issue as as duplicate of #21992. |
zsenyeg opened SPR-17617 and commented
RequestHeaderMethodArgumentResolver
createsRequestHeaderNamedValueInfo
information from annotation using only name value of RequestHeader annotation.In generated codes for example swagger codegen 3, only the value attribute is filled, and because of that in the rest interface the name of the method argument will be used, that is might be different than the name (or value) of the RequestHeader annotation.
For example:
Name attribute of annotation is not filled, because of that method argument name consentId will be used, and won't found among the http request headers.
Affects: 5.1.2
Attachments:
The text was updated successfully, but these errors were encountered: