After upgrading to Spring 5.2.1 many unit tests mocking responses using Spring's MockHttpServletResponse which set a Set-Cookie header including Expires=0 suddenly fail like this:
java.time.format.DateTimeParseException: Text '0' could not be parsed at index 1
at java.base/java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:2046)
at java.base/java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1948)
at java.base/java.time.ZonedDateTime.parse(ZonedDateTime.java:598)
at org.springframework.mock.web.MockCookie.parse(MockCookie.java:122)
The reason seems to be the current implementation of following new feature: Preserve expires attribute in MockCookie #23769, which according to my understanding does not correctly handle all Cookie attribute values of the Expires attribute.
See also RFC 2616 14.21, RFC 6265 5.3, and RFC 7234 5.3.
A cache recipient MUST interpret invalid date formats, especially the value "0", as representing a time in the past (i.e., "already expired").
Relevant commit introducing the regression: 9b20876
I think a parse error should at least be caught and ignored here.
After upgrading to Spring 5.2.1 many unit tests mocking responses using Spring's
MockHttpServletResponsewhich set aSet-Cookieheader includingExpires=0suddenly fail like this:The reason seems to be the current implementation of following new feature: Preserve expires attribute in MockCookie #23769, which according to my understanding does not correctly handle all
Cookieattribute values of theExpiresattribute.See also RFC 2616 14.21, RFC 6265 5.3, and RFC 7234 5.3.
Relevant commit introducing the regression: 9b20876
I think a parse error should at least be caught and ignored here.