From a416f496c037b24b9f81a032b564f02f6a29a200 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 18 Oct 2016 20:43:05 +0100 Subject: [PATCH] Clean up deprecation and unused code warnings --- .../CacheStatisticsAutoConfiguration.java | 6 +++--- .../actuate/autoconfigure/CrshAutoConfiguration.java | 2 ++ .../boot/actuate/endpoint/InfoEndpoint.java | 11 ----------- .../actuate/autoconfigure/ShellPropertiesTests.java | 2 ++ .../boot/autoconfigure/cache/CacheConfigurations.java | 7 ++++++- .../autoconfigure/cache/GuavaCacheConfiguration.java | 1 + .../boot/autoconfigure/web/ServerProperties.java | 6 +++--- .../org/springframework/boot/SpringApplication.java | 2 -- .../UndertowEmbeddedServletContainerFactory.java | 8 ++------ 9 files changed, 19 insertions(+), 26 deletions(-) diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/CacheStatisticsAutoConfiguration.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/CacheStatisticsAutoConfiguration.java index 99ee83f9eeba..10c171a8238c 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/CacheStatisticsAutoConfiguration.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/CacheStatisticsAutoConfiguration.java @@ -31,7 +31,6 @@ import org.springframework.boot.actuate.cache.ConcurrentMapCacheStatisticsProvider; import org.springframework.boot.actuate.cache.DefaultCacheStatistics; import org.springframework.boot.actuate.cache.EhCacheStatisticsProvider; -import org.springframework.boot.actuate.cache.GuavaCacheStatisticsProvider; import org.springframework.boot.actuate.cache.HazelcastCacheStatisticsProvider; import org.springframework.boot.actuate.cache.InfinispanCacheStatisticsProvider; import org.springframework.boot.actuate.cache.JCacheCacheStatisticsProvider; @@ -121,11 +120,12 @@ public CaffeineCacheStatisticsProvider caffeineCacheStatisticsProvider() { @Configuration @ConditionalOnClass({ com.google.common.cache.Cache.class, GuavaCache.class }) + @Deprecated static class GuavaCacheStatisticsConfiguration { @Bean - public GuavaCacheStatisticsProvider guavaCacheStatisticsProvider() { - return new GuavaCacheStatisticsProvider(); + public org.springframework.boot.actuate.cache.GuavaCacheStatisticsProvider guavaCacheStatisticsProvider() { + return new org.springframework.boot.actuate.cache.GuavaCacheStatisticsProvider(); } } diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/CrshAutoConfiguration.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/CrshAutoConfiguration.java index cfa70b8e809f..6fb736d16229 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/CrshAutoConfiguration.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/CrshAutoConfiguration.java @@ -142,6 +142,7 @@ public CrshBootstrapBean shellBootstrap() { } @Configuration + @Deprecated static class CrshAdditionalPropertiesConfiguration { @Bean @@ -173,6 +174,7 @@ public SimpleAuthenticationProperties simpleAuthenticationProperties() { @Configuration @ConditionalOnProperty(prefix = AUTH_PREFIX, name = "type", havingValue = "spring", matchIfMissing = true) @ConditionalOnBean(AuthenticationManager.class) + @Deprecated public static class AuthenticationManagerAdapterConfiguration { private final ManagementServerProperties management; diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/InfoEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/InfoEndpoint.java index 98acc486ca4d..7c38b68d7744 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/InfoEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/InfoEndpoint.java @@ -16,14 +16,11 @@ package org.springframework.boot.actuate.endpoint; -import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Map; import org.springframework.boot.actuate.info.Info; import org.springframework.boot.actuate.info.InfoContributor; -import org.springframework.boot.actuate.info.MapInfoContributor; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.util.Assert; @@ -49,14 +46,6 @@ public InfoEndpoint(List infoContributors) { this.infoContributors = infoContributors; } - private static List createContributors(Map info, - InfoContributor[] infoContributors) { - List result = new ArrayList( - Arrays.asList(infoContributors)); - result.add(0, new MapInfoContributor(info)); - return result; - } - @Override public Map invoke() { Info.Builder builder = new Info.Builder(); diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/ShellPropertiesTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/ShellPropertiesTests.java index 1bdd66ce28b3..c77519ac1d47 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/ShellPropertiesTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/ShellPropertiesTests.java @@ -244,6 +244,7 @@ private T load(Class type, String... environment) { return this.context.getBean(type); } + @SuppressWarnings("deprecation") @Configuration @EnableConfigurationProperties({ ShellProperties.class, JaasAuthenticationProperties.class, KeyAuthenticationProperties.class, @@ -253,6 +254,7 @@ static class TestConfiguration { } @Configuration + @Deprecated public static class TestShellConfiguration { public static String uuid = UUID.randomUUID().toString(); diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheConfigurations.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheConfigurations.java index 226959064eb3..b31e46641607 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheConfigurations.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheConfigurations.java @@ -42,12 +42,17 @@ final class CacheConfigurations { mappings.put(CacheType.COUCHBASE, CouchbaseCacheConfiguration.class); mappings.put(CacheType.REDIS, RedisCacheConfiguration.class); mappings.put(CacheType.CAFFEINE, CaffeineCacheConfiguration.class); - mappings.put(CacheType.GUAVA, GuavaCacheConfiguration.class); + addGuavaMapping(mappings); mappings.put(CacheType.SIMPLE, SimpleCacheConfiguration.class); mappings.put(CacheType.NONE, NoOpCacheConfiguration.class); MAPPINGS = Collections.unmodifiableMap(mappings); } + @Deprecated + private static void addGuavaMapping(Map> mappings) { + mappings.put(CacheType.GUAVA, GuavaCacheConfiguration.class); + } + private CacheConfigurations() { } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/GuavaCacheConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/GuavaCacheConfiguration.java index 05fefa6be793..55cccb97e3d2 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/GuavaCacheConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/GuavaCacheConfiguration.java @@ -43,6 +43,7 @@ @ConditionalOnClass({ CacheBuilder.class, GuavaCacheManager.class }) @ConditionalOnMissingBean(CacheManager.class) @Conditional(CacheCondition.class) +@Deprecated class GuavaCacheConfiguration { private final CacheProperties cacheProperties; diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java index 9dbca47cd103..16cc1011ca54 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java @@ -66,6 +66,7 @@ import org.springframework.boot.context.embedded.undertow.UndertowBuilderCustomizer; import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; import org.springframework.boot.context.properties.NestedConfigurationProperty; import org.springframework.boot.web.servlet.ServletContextInitializer; import org.springframework.context.EnvironmentAware; @@ -1216,6 +1217,7 @@ public static class Undertow { /** * Number of buffer per region. */ + @Deprecated private Integer buffersPerRegion; /** @@ -1243,6 +1245,7 @@ public void setBufferSize(Integer bufferSize) { this.bufferSize = bufferSize; } + @DeprecatedConfigurationProperty(reason = "The property is not used by Undertow. See https://issues.jboss.org/browse/UNDERTOW-587 for details") public Integer getBuffersPerRegion() { return this.buffersPerRegion; } @@ -1284,9 +1287,6 @@ void customizeUndertow(final ServerProperties serverProperties, if (this.bufferSize != null) { factory.setBufferSize(this.bufferSize); } - if (this.buffersPerRegion != null) { - factory.setBuffersPerRegion(this.buffersPerRegion); - } if (this.ioThreads != null) { factory.setIoThreads(this.ioThreads); } diff --git a/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java b/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java index 4ef5b8819c4d..8740f78b7b1e 100644 --- a/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java +++ b/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java @@ -200,8 +200,6 @@ public class SpringApplication { private Banner banner; - private boolean printedCustomBannerViaDeprecatedMethod; - private ResourceLoader resourceLoader; private BeanNameGenerator beanNameGenerator; diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactory.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactory.java index fd06f593903a..377ded6adc7b 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactory.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactory.java @@ -110,8 +110,6 @@ public class UndertowEmbeddedServletContainerFactory private Integer bufferSize; - private Integer buffersPerRegion; - private Integer ioThreads; private Integer workerThreads; @@ -236,9 +234,6 @@ private Builder createBuilder(int port) { if (this.bufferSize != null) { builder.setBufferSize(this.bufferSize); } - if (this.buffersPerRegion != null) { - builder.setBuffersPerRegion(this.buffersPerRegion); - } if (this.ioThreads != null) { builder.setIoThreads(this.ioThreads); } @@ -544,8 +539,9 @@ public void setBufferSize(Integer bufferSize) { this.bufferSize = bufferSize; } + @Deprecated public void setBuffersPerRegion(Integer buffersPerRegion) { - this.buffersPerRegion = buffersPerRegion; + } public void setIoThreads(Integer ioThreads) {