From 3e939cbabdd8f5bcb0b10b802fce91419dff0930 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Fri, 14 Aug 2020 17:02:13 -0700 Subject: [PATCH 1/2] Polish method order --- .../builder/SpringApplicationBuilder.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java index 5f7efcd0f5e..33e0707fd1f 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java @@ -381,16 +381,6 @@ public class SpringApplicationBuilder { return this; } - /** - * Default properties for the environment in the form {@code key=value} or - * {@code key:value}. - * @param defaultProperties the properties to set. - * @return the current builder - */ - public SpringApplicationBuilder properties(String... defaultProperties) { - return properties(getMapFromKeyValuePairs(defaultProperties)); - } - /** * Flag to control whether the application should be initialized lazily. * @param lazyInitialization the flag to set. Defaults to false. @@ -402,6 +392,16 @@ public class SpringApplicationBuilder { return this; } + /** + * Default properties for the environment in the form {@code key=value} or + * {@code key:value}. + * @param defaultProperties the properties to set. + * @return the current builder + */ + public SpringApplicationBuilder properties(String... defaultProperties) { + return properties(getMapFromKeyValuePairs(defaultProperties)); + } + private Map getMapFromKeyValuePairs(String[] properties) { Map map = new HashMap<>(); for (String property : properties) { From 89a6f83344dc0217cc658cdecfb2357e4c4a370d Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Fri, 14 Aug 2020 17:06:39 -0700 Subject: [PATCH 2/2] Fix and improve SpringApplicationBuilder javadoc Update SpringApplicationBuilder.properties method javadoc to fix inaccuracies and apply more consistency. Closes gh-22962 --- .../boot/builder/SpringApplicationBuilder.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java index 33e0707fd1f..0f0303c7f99 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java @@ -394,9 +394,12 @@ public class SpringApplicationBuilder { /** * Default properties for the environment in the form {@code key=value} or - * {@code key:value}. + * {@code key:value}. Multiple calls to this method are cumulative and will not clear + * any previously set properties. * @param defaultProperties the properties to set. * @return the current builder + * @see SpringApplicationBuilder#properties(Properties) + * @see SpringApplicationBuilder#properties(Map) */ public SpringApplicationBuilder properties(String... defaultProperties) { return properties(getMapFromKeyValuePairs(defaultProperties)); @@ -425,10 +428,12 @@ public class SpringApplicationBuilder { } /** - * Default properties for the environment in the form {@code key=value} or - * {@code key:value}. + * Default properties for the environment.Multiple calls to this method are cumulative + * and will not clear any previously set properties. * @param defaultProperties the properties to set. * @return the current builder + * @see SpringApplicationBuilder#properties(String...) + * @see SpringApplicationBuilder#properties(Map) */ public SpringApplicationBuilder properties(Properties defaultProperties) { return properties(getMapFromProperties(defaultProperties)); @@ -444,10 +449,11 @@ public class SpringApplicationBuilder { /** * Default properties for the environment. Multiple calls to this method are - * cumulative. + * cumulative and will not clear any previously set properties. * @param defaults the default properties * @return the current builder * @see SpringApplicationBuilder#properties(String...) + * @see SpringApplicationBuilder#properties(Properties) */ public SpringApplicationBuilder properties(Map defaults) { this.defaultProperties.putAll(defaults);