mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-23 01:39:02 +00:00
Merge branch '3.4.x' into 3.5.x
Closes gh-47253
This commit is contained in:
+1
-1
@@ -1024,7 +1024,7 @@ public class ServerProperties {
|
||||
/**
|
||||
* Time-to-live of the static resource cache.
|
||||
*/
|
||||
private Duration cacheTtl;
|
||||
private Duration cacheTtl = Duration.ofSeconds(5);
|
||||
|
||||
public boolean isAllowCaching() {
|
||||
return this.allowCaching;
|
||||
|
||||
+15
-1
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.boot.autoconfigure.web.embedded;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Locale;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -321,6 +322,19 @@ class TomcatWebServerFactoryCustomizerTests {
|
||||
assertThat(remoteIpValve.getTrustedProxies()).isEqualTo("proxy1|proxy2");
|
||||
}
|
||||
|
||||
@Test
|
||||
void resourceCacheMatchesDefault() {
|
||||
ServerProperties properties = new ServerProperties();
|
||||
customizeAndRunServer((server) -> {
|
||||
Tomcat tomcat = server.getTomcat();
|
||||
Context context = (Context) tomcat.getHost().findChildren()[0];
|
||||
assertThat(properties.getTomcat().getResource().isAllowCaching())
|
||||
.isEqualTo(context.getResources().isCachingAllowed());
|
||||
assertThat(properties.getTomcat().getResource().getCacheTtl())
|
||||
.isEqualTo(Duration.ofMillis(context.getResources().getCacheTtl()));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void customStaticResourceAllowCaching() {
|
||||
bind("server.tomcat.resource.allow-caching=false");
|
||||
@@ -333,7 +347,7 @@ class TomcatWebServerFactoryCustomizerTests {
|
||||
|
||||
@Test
|
||||
void customStaticResourceCacheTtl() {
|
||||
bind("server.tomcat.resource.cache-ttl=10000");
|
||||
bind("server.tomcat.resource.cache-ttl=10s");
|
||||
customizeAndRunServer((server) -> {
|
||||
Tomcat tomcat = server.getTomcat();
|
||||
Context context = (Context) tomcat.getHost().findChildren()[0];
|
||||
|
||||
Reference in New Issue
Block a user