Deprecate resource "app-cache" configuration support

This commit deprecates the
`"spring.resources.chain.html-application-cache"` configuration property
and its support, since the feature has been deprecated in Spring
Framework.

The app-cache manifest feature is being removed from browsers in favor
of web workers.

Closes gh-23228
pull/23229/head
Brian Clozel 4 years ago
parent b9b7393053
commit 9e0fd01aae

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -21,6 +21,7 @@ import java.time.temporal.ChronoUnit;
import java.util.concurrent.TimeUnit;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
import org.springframework.boot.context.properties.PropertyMapper;
import org.springframework.boot.convert.DurationUnit;
import org.springframework.http.CacheControl;
@ -145,6 +146,8 @@ public class ResourceProperties {
return this.strategy;
}
@DeprecatedConfigurationProperty(reason = "The appcache manifest feature is being removed from browsers.")
@Deprecated
public boolean isHtmlApplicationCache() {
return this.htmlApplicationCache;
}

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,7 +20,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.ResourceProperties;
import org.springframework.web.reactive.config.ResourceChainRegistration;
import org.springframework.web.reactive.config.ResourceHandlerRegistration;
import org.springframework.web.reactive.resource.AppCacheManifestTransformer;
import org.springframework.web.reactive.resource.EncodedResourceResolver;
import org.springframework.web.reactive.resource.ResourceResolver;
import org.springframework.web.reactive.resource.VersionResourceResolver;
@ -42,6 +41,7 @@ class ResourceChainResourceHandlerRegistrationCustomizer implements ResourceHand
configureResourceChain(properties, registration.resourceChain(properties.isCache()));
}
@SuppressWarnings("deprecation")
private void configureResourceChain(ResourceProperties.Chain properties, ResourceChainRegistration chain) {
ResourceProperties.Strategy strategy = properties.getStrategy();
if (properties.isCompressed()) {
@ -51,7 +51,7 @@ class ResourceChainResourceHandlerRegistrationCustomizer implements ResourceHand
chain.addResolver(getVersionResourceResolver(strategy));
}
if (properties.isHtmlApplicationCache()) {
chain.addTransformer(new AppCacheManifestTransformer());
chain.addTransformer(new org.springframework.web.reactive.resource.AppCacheManifestTransformer());
}
}

@ -111,7 +111,6 @@ import org.springframework.web.servlet.i18n.FixedLocaleResolver;
import org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import org.springframework.web.servlet.resource.AppCacheManifestTransformer;
import org.springframework.web.servlet.resource.EncodedResourceResolver;
import org.springframework.web.servlet.resource.ResourceResolver;
import org.springframework.web.servlet.resource.ResourceUrlProvider;
@ -564,6 +563,7 @@ public class WebMvcAutoConfiguration {
configureResourceChain(properties, registration.resourceChain(properties.isCache()));
}
@SuppressWarnings("deprecation")
private void configureResourceChain(ResourceProperties.Chain properties, ResourceChainRegistration chain) {
Strategy strategy = properties.getStrategy();
if (properties.isCompressed()) {
@ -573,7 +573,7 @@ public class WebMvcAutoConfiguration {
chain.addResolver(getVersionResourceResolver(strategy));
}
if (properties.isHtmlApplicationCache()) {
chain.addTransformer(new AppCacheManifestTransformer());
chain.addTransformer(new org.springframework.web.servlet.resource.AppCacheManifestTransformer());
}
}

@ -105,7 +105,6 @@ import org.springframework.web.servlet.i18n.FixedLocaleResolver;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver;
import org.springframework.web.servlet.resource.AppCacheManifestTransformer;
import org.springframework.web.servlet.resource.CachingResourceResolver;
import org.springframework.web.servlet.resource.CachingResourceTransformer;
import org.springframework.web.servlet.resource.ContentVersionStrategy;
@ -255,6 +254,7 @@ class WebMvcAutoConfigurationTests {
}
@Test
@SuppressWarnings("deprecation")
void resourceHandlerChainCustomized() {
this.contextRunner
.withPropertyValues("spring.resources.chain.enabled:true", "spring.resources.chain.cache:false",
@ -269,8 +269,9 @@ class WebMvcAutoConfigurationTests {
assertThat(getResourceTransformers(context, "/webjars/**")).hasSize(2);
assertThat(getResourceResolvers(context, "/**")).extractingResultOf("getClass").containsOnly(
EncodedResourceResolver.class, VersionResourceResolver.class, PathResourceResolver.class);
assertThat(getResourceTransformers(context, "/**")).extractingResultOf("getClass")
.containsOnly(CssLinkResourceTransformer.class, AppCacheManifestTransformer.class);
assertThat(getResourceTransformers(context, "/**")).extractingResultOf("getClass").containsOnly(
CssLinkResourceTransformer.class,
org.springframework.web.servlet.resource.AppCacheManifestTransformer.class);
VersionResourceResolver resolver = (VersionResourceResolver) getResourceResolvers(context, "/**")
.get(1);
Map<String, VersionStrategy> strategyMap = resolver.getStrategyMap();

Loading…
Cancel
Save