diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfiguration.java index bf21f5c965..857d3e7d4d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfiguration.java @@ -64,22 +64,24 @@ public class FreeMarkerAutoConfiguration { @PostConstruct public void checkTemplateLocationExists() { - if (this.properties.isCheckTemplateLocation()) { - TemplateLocation templatePathLocation = null; - List locations = new ArrayList<>(); - for (String templateLoaderPath : this.properties.getTemplateLoaderPath()) { - TemplateLocation location = new TemplateLocation(templateLoaderPath); - locations.add(location); - if (location.exists(this.applicationContext)) { - templatePathLocation = location; - break; + if (logger.isWarnEnabled()) { + if (this.properties.isCheckTemplateLocation()) { + TemplateLocation templatePathLocation = null; + List locations = new ArrayList<>(); + for (String templateLoaderPath : this.properties.getTemplateLoaderPath()) { + TemplateLocation location = new TemplateLocation(templateLoaderPath); + locations.add(location); + if (location.exists(this.applicationContext)) { + templatePathLocation = location; + break; + } + } + if (templatePathLocation == null) { + logger.warn("Cannot find template location(s): " + locations + + " (please add some templates, " + + "check your FreeMarker configuration, or set " + + "spring.freemarker.checkTemplateLocation=false)"); } - } - if (templatePathLocation == null) { - logger.warn("Cannot find template location(s): " + locations - + " (please add some templates, " - + "check your FreeMarker configuration, or set " - + "spring.freemarker.checkTemplateLocation=false)"); } } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfigurationTests.java index 7927fb6e5a..c66f98f199 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfigurationTests.java @@ -55,7 +55,7 @@ public class DispatcherServletAutoConfigurationTests { assertThat(context.getBean(DispatcherServlet.class)).isNotNull(); ServletRegistrationBean registration = context .getBean(ServletRegistrationBean.class); - assertThat(registration.getUrlMappings().toString()).isEqualTo("[/]"); + assertThat(registration.getUrlMappings()).containsExactly("/"); }); } @@ -72,11 +72,11 @@ public class DispatcherServletAutoConfigurationTests { // from the default one, we're registering one anyway @Test public void registrationOverrideWithDispatcherServletWrongName() { - this.contextRunner.withUserConfiguration(CustomDispatcherServletWrongName.class) + this.contextRunner.withUserConfiguration(CustomDispatcherServletDifferentName.class) .run((context) -> { ServletRegistrationBean registration = context .getBean(ServletRegistrationBean.class); - assertThat(registration.getUrlMappings().toString()).isEqualTo("[/]"); + assertThat(registration.getUrlMappings()).containsExactly("/"); assertThat(registration.getServletName()) .isEqualTo("dispatcherServlet"); assertThat(context).getBeanNames(DispatcherServlet.class).hasSize(2); @@ -89,8 +89,8 @@ public class DispatcherServletAutoConfigurationTests { .run((context) -> { ServletRegistrationBean registration = context .getBean(ServletRegistrationBean.class); - assertThat(registration.getUrlMappings().toString()) - .isEqualTo("[/foo]"); + assertThat(registration.getUrlMappings()) + .containsExactly("/foo"); assertThat(registration.getServletName()) .isEqualTo("customDispatcher"); assertThat(context).hasSingleBean(DispatcherServlet.class); @@ -104,8 +104,8 @@ public class DispatcherServletAutoConfigurationTests { assertThat(context.getBean(DispatcherServlet.class)).isNotNull(); ServletRegistrationBean registration = context .getBean(ServletRegistrationBean.class); - assertThat(registration.getUrlMappings().toString()) - .isEqualTo("[/spring/*]"); + assertThat(registration.getUrlMappings()) + .containsExactly("/spring/*"); assertThat(registration.getMultipartConfig()).isNull(); assertThat(context.getBean(DispatcherServletPathProvider.class) .getServletPath()).isEqualTo("/spring"); @@ -189,7 +189,7 @@ public class DispatcherServletAutoConfigurationTests { } @Configuration - protected static class CustomDispatcherServletWrongName { + protected static class CustomDispatcherServletDifferentName { @Bean public DispatcherServlet customDispatcherServlet() { diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index 800c99a149..6018017951 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -1420,7 +1420,6 @@ content into your application. Rather, pick only the properties that you need. management.metrics.export.statsd.polling-frequency=10s # How often gauges will be polled. When a gauge is polled, its value is recalculated and if the value has changed (or publishUnchangedMeters is true), it is sent to the StatsD server. management.metrics.export.statsd.port=8125 # Port of the StatsD server to receive exported metrics. management.metrics.export.statsd.publish-unchanged-meters=true # Whether to send unchanged meters to the StatsD server. - management.metrics.export.statsd.queue-size=2147483647 # Maximum size of the queue of items waiting to be sent to the StatsD server. management.metrics.export.wavefront.api-token= # API token used when publishing metrics directly to the Wavefront API host. management.metrics.export.wavefront.batch-size=10000 # Number of measurements per request to use for this backend. If more measurements are found, then multiple requests will be made. management.metrics.export.wavefront.connect-timeout=1s # Connection timeout for requests to this backend. diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc index 2e1bfa61d3..52664dd22b 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc @@ -1619,7 +1619,7 @@ environment that forwards metrics data to the Wavefront API host: [source,properties,indent=0] ---- - management.metrics.export.uri=proxy://localhost:2878 + management.metrics.export.wavefront.uri=proxy://localhost:2878 ---- TIP: If publishing metrics to a Wavefront proxy (as described in diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/SentenceExtractor.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/SentenceExtractor.java index e4a8be86b5..202b4b457b 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/SentenceExtractor.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/SentenceExtractor.java @@ -17,7 +17,9 @@ package org.springframework.boot.configurationmetadata; import java.text.BreakIterator; +import java.util.Arrays; import java.util.Locale; +import java.util.stream.Collectors; /** * Utility to extract the first sentence of a text. @@ -45,11 +47,7 @@ class SentenceExtractor { private String removeSpaceBetweenLine(String text) { String[] lines = text.split(System.lineSeparator()); - StringBuilder sb = new StringBuilder(); - for (String line : lines) { - sb.append(line.trim()).append(" "); - } - return sb.toString().trim(); + return Arrays.stream(lines).map(String::trim).collect(Collectors.joining(" ")); } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/ZipHeaderPeekInputStreamTests.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/ZipHeaderPeekInputStreamTests.java index e177f400ec..4eb15d2ba1 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/ZipHeaderPeekInputStreamTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/ZipHeaderPeekInputStreamTests.java @@ -42,7 +42,7 @@ public class ZipHeaderPeekInputStreamTests { } @Test - public void hasZipHeaderReturnsFalseWheStreamDoesNotStartWithZipHeader() + public void hasZipHeaderReturnsFalseWhenStreamDoesNotStartWithZipHeader() throws IOException { try (ZipHeaderPeekInputStream in = new ZipHeaderPeekInputStream( new ByteArrayInputStream(new byte[] { 0, 1, 2, 3, 4, 5 }))) { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java index 729264e99b..facab4b4b6 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java @@ -496,7 +496,7 @@ public class JarFileTests { .openConnection().getInputStream().close(); this.thrown.expect(FileNotFoundException.class); new URL(context, "jar:" + this.rootJarFile.toURI() + "!/no.dat") - .openConnection().getInputStream().close(); + .openConnection().getInputStream(); } finally { JarURLConnection.setUseFastExceptions(false); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java index 4d6effaf3f..f0d34b345e 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java @@ -252,8 +252,7 @@ public class Binder { } private Object bindObject(ConfigurationPropertyName name, Bindable target, - BindHandler handler, Context context, boolean allowRecursiveBinding) - throws Exception { + BindHandler handler, Context context, boolean allowRecursiveBinding) { ConfigurationProperty property = findProperty(name, context); if (property == null && containsNoDescendantOf(context.streamSources(), name)) { return null; diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/CollectionBinderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/CollectionBinderTests.java index da407edb73..25dade2c2b 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/CollectionBinderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/CollectionBinderTests.java @@ -414,7 +414,7 @@ public class CollectionBinderTests { this.sources.add(source); Bindable target = Bindable.of(ClonedArrayBean.class); ClonedArrayBean bean = this.binder.bind("foo", target).get(); - assertThat(bean.getBar()).contains("hello"); + assertThat(bean.getBar()).containsExactly("hello"); } public static class ExampleCollectionBean {