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
This commit is contained in:
Brian Clozel 2021-04-26 11:34:47 +02:00
parent e424c1c4b4
commit 7be9c268b8
2 changed files with 2 additions and 1 deletions

View File

@ -426,6 +426,7 @@ public class WebMvcAutoConfiguration {
customizer.accept(registration);
registration.setCachePeriod(getSeconds(this.resourceProperties.getCache().getPeriod()));
registration.setCacheControl(this.resourceProperties.getCache().getCachecontrol().toHttpCacheControl());
registration.setUseLastModified(this.resourceProperties.getCache().isUseLastModified());
customizeResourceHandlerRegistration(registration);
}

View File

@ -1009,7 +1009,7 @@ class WebMvcAutoConfigurationTests {
Consumer<ResourceHttpRequestHandler> handlerConsumer) {
Map<String, Object> handlerMap = getHandlerMap(context.getBean("resourceHandlerMapping", HandlerMapping.class));
assertThat(handlerMap).hasSize(2);
for (Object handler : handlerMap.keySet()) {
for (Object handler : handlerMap.values()) {
if (handler instanceof ResourceHttpRequestHandler) {
handlerConsumer.accept((ResourceHttpRequestHandler) handler);
}