-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Ignore null header value in MockHttpServletResponse #26488
Comments
The Javadoc for
And as you pointed out, However, the Tomcat implementation ( So I'm a bit undecided about whether we should remove the not-null assertion in @rstoyanchev, thoughts? |
On second thought, since neither Tomcat nor Jetty throws an @rstoyanchev / @jhoeller, are you OK with that? |
This change will be included in 5.3.4, but feel free to try it out in an upcoming 5.3.4 snapshot. |
@sbrannen Thanks, appreciate your quick response. |
Hello,
I've faced an issue recently working with
MockHttpServletResponse
. The thing is when I have conditional (value can be null) headers in my controller, and I want to test them usingMockMvc
it fails, becauseMockHttpServletResponse
checks if header value in response isnull
.Below is what I am trying to do:
So the intention is to send header if its value is present and it works as expected. But when I test it with
MockMvc
it throws anIllegalArgumentException
due to this check inMockHttpServletResponse
:I know that as workaround instead of nullability of value of header I can put headers themselves conditionally, but the thing is that spec of
HttpServletResponse
allows me to have nullable header values, whileMockHttpServletResponse
does not, and this behavior is surprising to say the least.The text was updated successfully, but these errors were encountered: