Commit 7be9c268 authored by Brian Clozel's avatar Brian Clozel

Fix ignored use-last-modified property in Spring MVC

Prior to this commit, the `spring.web.resources.cache.use-last-modified`
configuration property support was lost during a merge operation right
before 2.4.2.

This is due to an invalid test that missed this unintended change. This
commit fixes both problems.

Fixes gh-26212
parent e424c1c4
...@@ -426,6 +426,7 @@ public class WebMvcAutoConfiguration { ...@@ -426,6 +426,7 @@ public class WebMvcAutoConfiguration {
customizer.accept(registration); customizer.accept(registration);
registration.setCachePeriod(getSeconds(this.resourceProperties.getCache().getPeriod())); registration.setCachePeriod(getSeconds(this.resourceProperties.getCache().getPeriod()));
registration.setCacheControl(this.resourceProperties.getCache().getCachecontrol().toHttpCacheControl()); registration.setCacheControl(this.resourceProperties.getCache().getCachecontrol().toHttpCacheControl());
registration.setUseLastModified(this.resourceProperties.getCache().isUseLastModified());
customizeResourceHandlerRegistration(registration); customizeResourceHandlerRegistration(registration);
} }
......
...@@ -1009,7 +1009,7 @@ class WebMvcAutoConfigurationTests { ...@@ -1009,7 +1009,7 @@ class WebMvcAutoConfigurationTests {
Consumer<ResourceHttpRequestHandler> handlerConsumer) { Consumer<ResourceHttpRequestHandler> handlerConsumer) {
Map<String, Object> handlerMap = getHandlerMap(context.getBean("resourceHandlerMapping", HandlerMapping.class)); Map<String, Object> handlerMap = getHandlerMap(context.getBean("resourceHandlerMapping", HandlerMapping.class));
assertThat(handlerMap).hasSize(2); assertThat(handlerMap).hasSize(2);
for (Object handler : handlerMap.keySet()) { for (Object handler : handlerMap.values()) {
if (handler instanceof ResourceHttpRequestHandler) { if (handler instanceof ResourceHttpRequestHandler) {
handlerConsumer.accept((ResourceHttpRequestHandler) handler); handlerConsumer.accept((ResourceHttpRequestHandler) handler);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment