Description
Oliver Drotbohm opened SPR-13090 and commented
As of version 4.2 RC1 ServletWebRequest
has a checkNotModified(String, long)
method, that – unexpectedly – sets headers (the method name does not imply that). Even worse, it calls setDateHeader(…)
on the response, which writes the given timestamp as is. This is wrong as per HTTP spec the value has to be a formatted date.
So if you set a Last-Modified
header in a controller and return a ResponseEntity
, the just mentioned check adds an invalid header to the response and later on adds the actually correct value as second value for that parameter.
Trying to access the header value then finally fails with an execption as HttpHeaders.getLastModified()
tries to parse the first value found into a Date
which it can't because of the invalid format.
I'd argue:
- a
check…
method that changes the state of the object is weird - why does that method set headers at all? If the header in question (
Last-Modified
in this case) is present it will be added later on by definition. Why create a second code path that writes headers and bypasses the code paths making sure headers are in the right format
I'd expect a single header value to be present in the response in the correct format.
The issue can be verified running https://github.com/spring-projects/spring-data-examples/tree/master/rest/headers and changing the Spring version to be used to anything 4.2.
Affects: 4.2 RC1
Issue Links:
- ETag/If-None-Match logic in HttpEntityMethodProcessor should not affect methods other than HTTP GET [SPR-13496] #18074 ETag/If-None-Match logic in HttpEntityMethodProcessor should not affect methods other than HTTP GET
- ServletWebRequest.checkNotModified attempts to call HttpServletResponse.getStatus() on Servlet 2.5 [SPR-13396] #17976 ServletWebRequest.checkNotModified attempts to call HttpServletResponse.getStatus() on Servlet 2.5
Referenced from: commits dba46c1, 39d689d, a421bd2, e2c8d37, 0175068
0 votes, 5 watchers