You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a MockHttpServletRequest is built using the MockHttpServletRequestBuilder in Spring MVC Test and no cookies are added, the getCookies() method returns an empty array.
However, according to the Servlet API, an implementation of HttpServletRequest.getCookies() must return nullif the request has no cookies.
Return null instead of empty cookies array in Spring MVC Test
Prior to this commit, MockHttpServletRequestBuilder always supplied an array of cookies to the MockHttpServletRequest that it built, even if the array was empty.
However, this violates the contract of HttpServletRequest. According to the Servlet API, the getCookies() method "returns null if no cookies were sent."
This commit ensures that MockHttpServletRequestBuilder no longer configures an empty array of cookies in the mock request that it builds.
Joan Parera opened SPR-13314 and commented
If a
MockHttpServletRequest
is built using theMockHttpServletRequestBuilder
in Spring MVC Test and no cookies are added, thegetCookies()
method returns an empty array.However, according to the Servlet API, an implementation of
HttpServletRequest.getCookies()
must returnnull
if the request has no cookies.Affects: 3.2 GA
Referenced from: commits 93c07e7
The text was updated successfully, but these errors were encountered: