Commit 00b2954e authored by Brian Clozel's avatar Brian Clozel

Merge pull request #16730 from eiselems

* pr/16730:
  Fix 'spring.resources.cache.period' for WebMvc
parents 0b4934d1 94a9748c
......@@ -476,6 +476,10 @@ public class ResourceProperties {
.staleIfError(duration.getSeconds(), TimeUnit.SECONDS));
map.from(this::getSMaxAge).whenNonNull().to((duration) -> control
.sMaxAge(duration.getSeconds(), TimeUnit.SECONDS));
// check if cacheControl remained untouched
if (control.getHeaderValue() == null) {
return null;
}
return control;
}
......
......@@ -76,7 +76,7 @@ public class ResourcePropertiesTests {
public void emptyCacheControl() {
CacheControl cacheControl = this.properties.getCache().getCachecontrol()
.toHttpCacheControl();
assertThat(cacheControl.getHeaderValue()).isNull();
assertThat(cacheControl).isNull();
}
@Test
......
......@@ -803,13 +803,12 @@ public class WebMvcAutoConfigurationTests {
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) {
assertThat(((ResourceHttpRequestHandler) handler).getCacheSeconds())
.isEqualTo(-1);
.isEqualTo(5);
assertThat(((ResourceHttpRequestHandler) handler).getCacheControl())
.isEqualToComparingFieldByField(
CacheControl.maxAge(5, TimeUnit.SECONDS));
.isNull();
}
}
}
......
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