Merge branch '2.1.x'

pull/16831/head
Brian Clozel 6 years ago
commit 930186e505

@ -476,6 +476,10 @@ public class ResourceProperties {
.staleIfError(duration.getSeconds(), TimeUnit.SECONDS)); .staleIfError(duration.getSeconds(), TimeUnit.SECONDS));
map.from(this::getSMaxAge).whenNonNull().to((duration) -> control map.from(this::getSMaxAge).whenNonNull().to((duration) -> control
.sMaxAge(duration.getSeconds(), TimeUnit.SECONDS)); .sMaxAge(duration.getSeconds(), TimeUnit.SECONDS));
// check if cacheControl remained untouched
if (control.getHeaderValue() == null) {
return null;
}
return control; return control;
} }

@ -76,7 +76,7 @@ public class ResourcePropertiesTests {
public void emptyCacheControl() { public void emptyCacheControl() {
CacheControl cacheControl = this.properties.getCache().getCachecontrol() CacheControl cacheControl = this.properties.getCache().getCachecontrol()
.toHttpCacheControl(); .toHttpCacheControl();
assertThat(cacheControl.getHeaderValue()).isNull(); assertThat(cacheControl).isNull();
} }
@Test @Test

@ -803,13 +803,12 @@ public class WebMvcAutoConfigurationTests {
Map<String, Object> handlerMap = getHandlerMap( Map<String, Object> handlerMap = getHandlerMap(
context.getBean("resourceHandlerMapping", HandlerMapping.class)); 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) {
assertThat(((ResourceHttpRequestHandler) handler).getCacheSeconds()) assertThat(((ResourceHttpRequestHandler) handler).getCacheSeconds())
.isEqualTo(-1); .isEqualTo(5);
assertThat(((ResourceHttpRequestHandler) handler).getCacheControl()) assertThat(((ResourceHttpRequestHandler) handler).getCacheControl())
.isEqualToComparingFieldByField( .isNull();
CacheControl.maxAge(5, TimeUnit.SECONDS));
} }
} }
} }

Loading…
Cancel
Save