From 66b69f4346f4ca9a45e4fa1fbe0105c0e87aeba0 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Fri, 13 May 2016 19:00:34 -0700 Subject: [PATCH] Deprecate setProperties on ConfigurationFactory Deprecate `PropertiesConfigurationFactory.setProperties()` since it was only being used in tests. Fixes gh-5930 --- .../boot/bind/PropertiesConfigurationFactory.java | 4 ++++ .../boot/bind/PropertiesConfigurationFactoryMapTests.java | 1 + .../PropertiesConfigurationFactoryParameterizedTests.java | 1 + .../boot/bind/PropertiesConfigurationFactoryTests.java | 1 + 4 files changed, 7 insertions(+) diff --git a/spring-boot/src/main/java/org/springframework/boot/bind/PropertiesConfigurationFactory.java b/spring-boot/src/main/java/org/springframework/boot/bind/PropertiesConfigurationFactory.java index 6e328126de..6ce1bf1c7e 100644 --- a/spring-boot/src/main/java/org/springframework/boot/bind/PropertiesConfigurationFactory.java +++ b/spring-boot/src/main/java/org/springframework/boot/bind/PropertiesConfigurationFactory.java @@ -35,6 +35,7 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.context.MessageSource; import org.springframework.context.MessageSourceAware; import org.springframework.core.convert.ConversionService; +import org.springframework.core.env.PropertiesPropertySource; import org.springframework.core.env.PropertySources; import org.springframework.util.Assert; import org.springframework.util.StringUtils; @@ -161,7 +162,10 @@ public class PropertiesConfigurationFactory /** * Set the properties. * @param properties the properties + * @deprecated as of 1.4 in favor of {@link #setPropertySources(PropertySources) + * setPropertySources} that contains a {@link PropertiesPropertySource}. */ + @Deprecated public void setProperties(Properties properties) { this.properties = properties; } diff --git a/spring-boot/src/test/java/org/springframework/boot/bind/PropertiesConfigurationFactoryMapTests.java b/spring-boot/src/test/java/org/springframework/boot/bind/PropertiesConfigurationFactoryMapTests.java index d3154266d7..7a4bb4a6ca 100644 --- a/spring-boot/src/test/java/org/springframework/boot/bind/PropertiesConfigurationFactoryMapTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/bind/PropertiesConfigurationFactoryMapTests.java @@ -95,6 +95,7 @@ public class PropertiesConfigurationFactoryMapTests { return bindFoo(values); } + @Deprecated private Foo bindFoo(final String values) throws Exception { this.factory.setProperties(PropertiesLoaderUtils .loadProperties(new ByteArrayResource(values.getBytes()))); diff --git a/spring-boot/src/test/java/org/springframework/boot/bind/PropertiesConfigurationFactoryParameterizedTests.java b/spring-boot/src/test/java/org/springframework/boot/bind/PropertiesConfigurationFactoryParameterizedTests.java index 0c893a50b2..adf07218d4 100644 --- a/spring-boot/src/test/java/org/springframework/boot/bind/PropertiesConfigurationFactoryParameterizedTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/bind/PropertiesConfigurationFactoryParameterizedTests.java @@ -102,6 +102,7 @@ public class PropertiesConfigurationFactoryParameterizedTests { return bindFoo(values); } + @Deprecated private Foo bindFoo(final String values) throws Exception { Properties properties = PropertiesLoaderUtils .loadProperties(new ByteArrayResource(values.getBytes())); diff --git a/spring-boot/src/test/java/org/springframework/boot/bind/PropertiesConfigurationFactoryTests.java b/spring-boot/src/test/java/org/springframework/boot/bind/PropertiesConfigurationFactoryTests.java index c1de177ca2..cf32dd31bc 100644 --- a/spring-boot/src/test/java/org/springframework/boot/bind/PropertiesConfigurationFactoryTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/bind/PropertiesConfigurationFactoryTests.java @@ -169,6 +169,7 @@ public class PropertiesConfigurationFactoryTests { return bindFoo(values); } + @Deprecated private Foo bindFoo(final String values) throws Exception { this.factory.setProperties(PropertiesLoaderUtils .loadProperties(new ByteArrayResource(values.getBytes())));