Skip to content

Commit 209d4ab

Browse files
committed
Merge branch '3.4.x' into 3.5.x
Closes gh-47253
2 parents fae6b0a + 6f18f1b commit 209d4ab

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ public static class Resource {
10241024
/**
10251025
* Time-to-live of the static resource cache.
10261026
*/
1027-
private Duration cacheTtl;
1027+
private Duration cacheTtl = Duration.ofSeconds(5);
10281028

10291029
public boolean isAllowCaching() {
10301030
return this.allowCaching;

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.boot.autoconfigure.web.embedded;
1818

19+
import java.time.Duration;
1920
import java.util.Locale;
2021
import java.util.function.Consumer;
2122

@@ -321,6 +322,19 @@ void customRemoteIpValve() {
321322
assertThat(remoteIpValve.getTrustedProxies()).isEqualTo("proxy1|proxy2");
322323
}
323324

325+
@Test
326+
void resourceCacheMatchesDefault() {
327+
ServerProperties properties = new ServerProperties();
328+
customizeAndRunServer((server) -> {
329+
Tomcat tomcat = server.getTomcat();
330+
Context context = (Context) tomcat.getHost().findChildren()[0];
331+
assertThat(properties.getTomcat().getResource().isAllowCaching())
332+
.isEqualTo(context.getResources().isCachingAllowed());
333+
assertThat(properties.getTomcat().getResource().getCacheTtl())
334+
.isEqualTo(Duration.ofMillis(context.getResources().getCacheTtl()));
335+
});
336+
}
337+
324338
@Test
325339
void customStaticResourceAllowCaching() {
326340
bind("server.tomcat.resource.allow-caching=false");
@@ -333,7 +347,7 @@ void customStaticResourceAllowCaching() {
333347

334348
@Test
335349
void customStaticResourceCacheTtl() {
336-
bind("server.tomcat.resource.cache-ttl=10000");
350+
bind("server.tomcat.resource.cache-ttl=10s");
337351
customizeAndRunServer((server) -> {
338352
Tomcat tomcat = server.getTomcat();
339353
Context context = (Context) tomcat.getHost().findChildren()[0];

0 commit comments

Comments
 (0)