Remove deprecated code flagged for removal

Closes gh-27303
This commit is contained in:
Stephane Nicoll
2021-07-14 11:49:52 +02:00
parent 46ad4c6f98
commit dc5acb0019
82 changed files with 183 additions and 2508 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 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.
@@ -23,8 +23,6 @@ import java.util.Map;
import org.apache.commons.logging.Log;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.properties.bind.BindResult;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.boot.devtools.logger.DevToolsLogFactory;
import org.springframework.boot.devtools.restart.Restarter;
import org.springframework.boot.devtools.system.DevToolsEnablementDeducer;
@@ -87,9 +85,7 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro
if (canAddProperties(environment)) {
logger.info(LogMessage.format("Devtools property defaults active! Set '%s' to 'false' to disable",
ENABLED));
Map<String, Object> properties = new HashMap<>(PROPERTIES);
properties.putAll(getResourceProperties(environment));
environment.getPropertySources().addLast(new MapPropertySource("devtools", properties));
environment.getPropertySources().addLast(new MapPropertySource("devtools", PROPERTIES));
}
if (isWebApplication(environment) && !environment.containsProperty(WEB_LOGGING)) {
logger.info(LogMessage.format(
@@ -99,27 +95,6 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro
}
}
private Map<String, String> getResourceProperties(Environment environment) {
Map<String, String> resourceProperties = new HashMap<>();
String prefix = determineResourcePropertiesPrefix(environment);
resourceProperties.put(prefix + "cache.period", "0");
resourceProperties.put(prefix + "chain.cache", "false");
return resourceProperties;
}
@SuppressWarnings("deprecation")
private String determineResourcePropertiesPrefix(Environment environment) {
if (ClassUtils.isPresent("org.springframework.boot.autoconfigure.web.ResourceProperties",
getClass().getClassLoader())) {
BindResult<org.springframework.boot.autoconfigure.web.ResourceProperties> result = Binder.get(environment)
.bind("spring.resources", org.springframework.boot.autoconfigure.web.ResourceProperties.class);
if (result.isBound() && result.get().hasBeenCustomized()) {
return "spring.resources.";
}
}
return "spring.web.resources.";
}
private boolean isLocalApplication(ConfigurableEnvironment environment) {
return environment.getPropertySources().get("remoteUrl") == null;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 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.
@@ -118,16 +118,6 @@ class LocalDevToolsAutoConfigurationTests {
assertThat(properties.getCache().getPeriod()).isZero();
}
@SuppressWarnings("deprecation")
@Test
void deprecatedResourceCachePeriodIsZeroWhenDeprecatedResourcePropertiesAreInUse() throws Exception {
this.context = getContext(() -> initializeAndRun(WebResourcesConfig.class,
Collections.singletonMap("spring.resources.add-mappings", false)));
Resources properties = this.context
.getBean(org.springframework.boot.autoconfigure.web.ResourceProperties.class);
assertThat(properties.getCache().getPeriod()).isZero();
}
@Test
void liveReloadServer() throws Exception {
this.context = getContext(() -> initializeAndRun(Config.class));
@@ -293,10 +283,9 @@ class LocalDevToolsAutoConfigurationTests {
}
@SuppressWarnings("deprecation")
@Configuration(proxyBeanMethods = false)
@Import({ ServletWebServerFactoryAutoConfiguration.class, LocalDevToolsAutoConfiguration.class, WebProperties.class,
org.springframework.boot.autoconfigure.web.ResourceProperties.class })
@Import({ ServletWebServerFactoryAutoConfiguration.class, LocalDevToolsAutoConfiguration.class,
WebProperties.class })
static class WebResourcesConfig {
}