From fb71174c24ba8f5778aec378a30a840c51b50816 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Thu, 23 Aug 2018 23:24:46 +0900 Subject: [PATCH] Polish Closes gh-14184 --- .../src/main/asciidoc/deployment.adoc | 2 +- .../main/asciidoc/spring-boot-features.adoc | 2 +- .../src/main/asciidoc/using-spring-boot.adoc | 2 +- .../boot/EnvironmentConverter.java | 6 ++---- .../boot/SpringApplication.java | 18 ++++++++++-------- .../boot/SpringApplicationTests.java | 12 ++++++------ 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/deployment.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/deployment.adoc index 2707c24c6e..73ddcd0be0 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/deployment.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/deployment.adoc @@ -847,7 +847,7 @@ application. [[deployment-whats-next]] == What to Read Next -Check out the https://www.cloudfoundry.com/[Cloud Foundry], +Check out the https://www.cloudfoundry.org/[Cloud Foundry], https://www.heroku.com/[Heroku], https://www.openshift.com[OpenShift], and https://boxfuse.com[Boxfuse] web sites for more information about the kinds of features that a PaaS can offer. These are just four of the most popular Java PaaS providers. Since diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 0d508401a3..a00302c04e 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -2000,7 +2000,7 @@ converters. You can also override default converters in the same way. ==== Custom JSON Serializers and Deserializers If you use Jackson to serialize and deserialize JSON data, you might want to write your own `JsonSerializer` and `JsonDeserializer` classes. Custom serializers are usually -http://wiki.fasterxml.com/JacksonHowToCustomDeserializers[registered with Jackson through +https://github.com/FasterXML/jackson-docs/wiki/JacksonHowToCustomSerializers[registered with Jackson through a module], but Spring Boot provides an alternative `@JsonComponent` annotation that makes it easier to directly register Spring Beans. diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/using-spring-boot.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/using-spring-boot.adoc index 20a4df7e30..d369d6adb5 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/using-spring-boot.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/using-spring-boot.adoc @@ -982,7 +982,7 @@ authors. The `spring-boot-devtools` module includes an embedded LiveReload server that can be used to trigger a browser refresh when a resource is changed. LiveReload browser extensions are freely available for Chrome, Firefox and Safari from -https://livereload.com/extensions/[livereload.com]. +http://livereload.com/extensions/[livereload.com]. If you do not want to start the LiveReload server when your application runs, you can set the `spring.devtools.livereload.enabled` property to `false`. diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/EnvironmentConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/EnvironmentConverter.java index 7e6c325c97..4482f01e82 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/EnvironmentConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/EnvironmentConverter.java @@ -125,10 +125,8 @@ final class EnvironmentConverter { names.add(propertySource.getName()); } for (String name : names) { - if (!isServletEnvironment) { - propertySources.remove(name); - } - else if (!SERVLET_ENVIRONMENT_SOURCE_NAMES.contains(name)) { + if (!isServletEnvironment + || !SERVLET_ENVIRONMENT_SOURCE_NAMES.contains(name)) { propertySources.remove(name); } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java index 586270b5fd..c03abea60a 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java @@ -372,13 +372,14 @@ public class SpringApplication { } private Class deduceEnvironmentClass() { - if (this.webApplicationType == WebApplicationType.SERVLET) { + switch (this.webApplicationType) { + case SERVLET: return StandardServletEnvironment.class; - } - if (this.webApplicationType == WebApplicationType.REACTIVE) { + case REACTIVE: return StandardReactiveWebEnvironment.class; + default: + return StandardEnvironment.class; } - return StandardEnvironment.class; } private void prepareContext(ConfigurableApplicationContext context, @@ -472,13 +473,14 @@ public class SpringApplication { if (this.environment != null) { return this.environment; } - if (this.webApplicationType == WebApplicationType.SERVLET) { + switch (this.webApplicationType) { + case SERVLET: return new StandardServletEnvironment(); - } - if (this.webApplicationType == WebApplicationType.REACTIVE) { + case REACTIVE: return new StandardReactiveWebEnvironment(); + default: + return new StandardEnvironment(); } - return new StandardEnvironment(); } /** diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java index 140212166e..8a4ee6cb7c 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java @@ -1122,9 +1122,9 @@ public class SpringApplicationTests { public void webApplicationConfiguredViaAPropertyHasTheCorrectTypeOfContextAndEnvironment() { ConfigurableApplicationContext context = new SpringApplication( ExampleWebConfig.class).run("--spring.main.web-application-type=servlet"); - assertThat(context).isInstanceOfAny(WebApplicationContext.class); + assertThat(context).isInstanceOf(WebApplicationContext.class); assertThat(context.getEnvironment()) - .isInstanceOfAny(StandardServletEnvironment.class); + .isInstanceOf(StandardServletEnvironment.class); } @Test @@ -1132,9 +1132,9 @@ public class SpringApplicationTests { ConfigurableApplicationContext context = new SpringApplication( ExampleReactiveWebConfig.class) .run("--spring.main.web-application-type=reactive"); - assertThat(context).isInstanceOfAny(ReactiveWebApplicationContext.class); + assertThat(context).isInstanceOf(ReactiveWebApplicationContext.class); assertThat(context.getEnvironment()) - .isInstanceOfAny(StandardReactiveWebEnvironment.class); + .isInstanceOf(StandardReactiveWebEnvironment.class); } @Test @@ -1142,9 +1142,9 @@ public class SpringApplicationTests { ConfigurableApplicationContext context = new SpringApplication( ExampleReactiveWebConfig.class) .run("--spring.profiles.active=withwebapplicationtype"); - assertThat(context).isInstanceOfAny(ReactiveWebApplicationContext.class); + assertThat(context).isInstanceOf(ReactiveWebApplicationContext.class); assertThat(context.getEnvironment()) - .isInstanceOfAny(StandardReactiveWebEnvironment.class); + .isInstanceOf(StandardReactiveWebEnvironment.class); } @Test