Skip to content

Commit 7be9c26

Browse files
committed
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
1 parent e424c1c commit 7be9c26

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ private void addResourceHandler(ResourceHandlerRegistry registry, String pattern
426426
customizer.accept(registration);
427427
registration.setCachePeriod(getSeconds(this.resourceProperties.getCache().getPeriod()));
428428
registration.setCacheControl(this.resourceProperties.getCache().getCachecontrol().toHttpCacheControl());
429+
registration.setUseLastModified(this.resourceProperties.getCache().isUseLastModified());
429430
customizeResourceHandlerRegistration(registration);
430431
}
431432

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ private void assertResourceHttpRequestHandler(AssertableWebApplicationContext co
10091009
Consumer<ResourceHttpRequestHandler> handlerConsumer) {
10101010
Map<String, Object> handlerMap = getHandlerMap(context.getBean("resourceHandlerMapping", HandlerMapping.class));
10111011
assertThat(handlerMap).hasSize(2);
1012-
for (Object handler : handlerMap.keySet()) {
1012+
for (Object handler : handlerMap.values()) {
10131013
if (handler instanceof ResourceHttpRequestHandler) {
10141014
handlerConsumer.accept((ResourceHttpRequestHandler) handler);
10151015
}

0 commit comments

Comments
 (0)