Commit b17c58b1 authored by Stephane Nicoll's avatar Stephane Nicoll

Merge branch '2.0.x'

parents 15edd02e 3dd2f5bb
...@@ -64,22 +64,24 @@ public class FreeMarkerAutoConfiguration { ...@@ -64,22 +64,24 @@ public class FreeMarkerAutoConfiguration {
@PostConstruct @PostConstruct
public void checkTemplateLocationExists() { public void checkTemplateLocationExists() {
if (this.properties.isCheckTemplateLocation()) { if (logger.isWarnEnabled()) {
TemplateLocation templatePathLocation = null; if (this.properties.isCheckTemplateLocation()) {
List<TemplateLocation> locations = new ArrayList<>(); TemplateLocation templatePathLocation = null;
for (String templateLoaderPath : this.properties.getTemplateLoaderPath()) { List<TemplateLocation> locations = new ArrayList<>();
TemplateLocation location = new TemplateLocation(templateLoaderPath); for (String templateLoaderPath : this.properties.getTemplateLoaderPath()) {
locations.add(location); TemplateLocation location = new TemplateLocation(templateLoaderPath);
if (location.exists(this.applicationContext)) { locations.add(location);
templatePathLocation = location; if (location.exists(this.applicationContext)) {
break; 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)");
} }
} }
} }
......
...@@ -55,7 +55,7 @@ public class DispatcherServletAutoConfigurationTests { ...@@ -55,7 +55,7 @@ public class DispatcherServletAutoConfigurationTests {
assertThat(context.getBean(DispatcherServlet.class)).isNotNull(); assertThat(context.getBean(DispatcherServlet.class)).isNotNull();
ServletRegistrationBean<?> registration = context ServletRegistrationBean<?> registration = context
.getBean(ServletRegistrationBean.class); .getBean(ServletRegistrationBean.class);
assertThat(registration.getUrlMappings().toString()).isEqualTo("[/]"); assertThat(registration.getUrlMappings()).containsExactly("/");
}); });
} }
...@@ -72,11 +72,11 @@ public class DispatcherServletAutoConfigurationTests { ...@@ -72,11 +72,11 @@ public class DispatcherServletAutoConfigurationTests {
// from the default one, we're registering one anyway // from the default one, we're registering one anyway
@Test @Test
public void registrationOverrideWithDispatcherServletWrongName() { public void registrationOverrideWithDispatcherServletWrongName() {
this.contextRunner.withUserConfiguration(CustomDispatcherServletWrongName.class) this.contextRunner.withUserConfiguration(CustomDispatcherServletDifferentName.class)
.run((context) -> { .run((context) -> {
ServletRegistrationBean<?> registration = context ServletRegistrationBean<?> registration = context
.getBean(ServletRegistrationBean.class); .getBean(ServletRegistrationBean.class);
assertThat(registration.getUrlMappings().toString()).isEqualTo("[/]"); assertThat(registration.getUrlMappings()).containsExactly("/");
assertThat(registration.getServletName()) assertThat(registration.getServletName())
.isEqualTo("dispatcherServlet"); .isEqualTo("dispatcherServlet");
assertThat(context).getBeanNames(DispatcherServlet.class).hasSize(2); assertThat(context).getBeanNames(DispatcherServlet.class).hasSize(2);
...@@ -89,8 +89,8 @@ public class DispatcherServletAutoConfigurationTests { ...@@ -89,8 +89,8 @@ public class DispatcherServletAutoConfigurationTests {
.run((context) -> { .run((context) -> {
ServletRegistrationBean<?> registration = context ServletRegistrationBean<?> registration = context
.getBean(ServletRegistrationBean.class); .getBean(ServletRegistrationBean.class);
assertThat(registration.getUrlMappings().toString()) assertThat(registration.getUrlMappings())
.isEqualTo("[/foo]"); .containsExactly("/foo");
assertThat(registration.getServletName()) assertThat(registration.getServletName())
.isEqualTo("customDispatcher"); .isEqualTo("customDispatcher");
assertThat(context).hasSingleBean(DispatcherServlet.class); assertThat(context).hasSingleBean(DispatcherServlet.class);
...@@ -104,8 +104,8 @@ public class DispatcherServletAutoConfigurationTests { ...@@ -104,8 +104,8 @@ public class DispatcherServletAutoConfigurationTests {
assertThat(context.getBean(DispatcherServlet.class)).isNotNull(); assertThat(context.getBean(DispatcherServlet.class)).isNotNull();
ServletRegistrationBean<?> registration = context ServletRegistrationBean<?> registration = context
.getBean(ServletRegistrationBean.class); .getBean(ServletRegistrationBean.class);
assertThat(registration.getUrlMappings().toString()) assertThat(registration.getUrlMappings())
.isEqualTo("[/spring/*]"); .containsExactly("/spring/*");
assertThat(registration.getMultipartConfig()).isNull(); assertThat(registration.getMultipartConfig()).isNull();
assertThat(context.getBean(DispatcherServletPathProvider.class) assertThat(context.getBean(DispatcherServletPathProvider.class)
.getServletPath()).isEqualTo("/spring"); .getServletPath()).isEqualTo("/spring");
...@@ -189,7 +189,7 @@ public class DispatcherServletAutoConfigurationTests { ...@@ -189,7 +189,7 @@ public class DispatcherServletAutoConfigurationTests {
} }
@Configuration @Configuration
protected static class CustomDispatcherServletWrongName { protected static class CustomDispatcherServletDifferentName {
@Bean @Bean
public DispatcherServlet customDispatcherServlet() { public DispatcherServlet customDispatcherServlet() {
......
...@@ -1420,7 +1420,6 @@ content into your application. Rather, pick only the properties that you need. ...@@ -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.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.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.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.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.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. management.metrics.export.wavefront.connect-timeout=1s # Connection timeout for requests to this backend.
......
...@@ -1619,7 +1619,7 @@ environment that forwards metrics data to the Wavefront API host: ...@@ -1619,7 +1619,7 @@ environment that forwards metrics data to the Wavefront API host:
[source,properties,indent=0] [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 TIP: If publishing metrics to a Wavefront proxy (as described in
......
...@@ -17,7 +17,9 @@ ...@@ -17,7 +17,9 @@
package org.springframework.boot.configurationmetadata; package org.springframework.boot.configurationmetadata;
import java.text.BreakIterator; import java.text.BreakIterator;
import java.util.Arrays;
import java.util.Locale; import java.util.Locale;
import java.util.stream.Collectors;
/** /**
* Utility to extract the first sentence of a text. * Utility to extract the first sentence of a text.
...@@ -45,11 +47,7 @@ class SentenceExtractor { ...@@ -45,11 +47,7 @@ class SentenceExtractor {
private String removeSpaceBetweenLine(String text) { private String removeSpaceBetweenLine(String text) {
String[] lines = text.split(System.lineSeparator()); String[] lines = text.split(System.lineSeparator());
StringBuilder sb = new StringBuilder(); return Arrays.stream(lines).map(String::trim).collect(Collectors.joining(" "));
for (String line : lines) {
sb.append(line.trim()).append(" ");
}
return sb.toString().trim();
} }
} }
...@@ -42,7 +42,7 @@ public class ZipHeaderPeekInputStreamTests { ...@@ -42,7 +42,7 @@ public class ZipHeaderPeekInputStreamTests {
} }
@Test @Test
public void hasZipHeaderReturnsFalseWheStreamDoesNotStartWithZipHeader() public void hasZipHeaderReturnsFalseWhenStreamDoesNotStartWithZipHeader()
throws IOException { throws IOException {
try (ZipHeaderPeekInputStream in = new ZipHeaderPeekInputStream( try (ZipHeaderPeekInputStream in = new ZipHeaderPeekInputStream(
new ByteArrayInputStream(new byte[] { 0, 1, 2, 3, 4, 5 }))) { new ByteArrayInputStream(new byte[] { 0, 1, 2, 3, 4, 5 }))) {
......
...@@ -496,7 +496,7 @@ public class JarFileTests { ...@@ -496,7 +496,7 @@ public class JarFileTests {
.openConnection().getInputStream().close(); .openConnection().getInputStream().close();
this.thrown.expect(FileNotFoundException.class); this.thrown.expect(FileNotFoundException.class);
new URL(context, "jar:" + this.rootJarFile.toURI() + "!/no.dat") new URL(context, "jar:" + this.rootJarFile.toURI() + "!/no.dat")
.openConnection().getInputStream().close(); .openConnection().getInputStream();
} }
finally { finally {
JarURLConnection.setUseFastExceptions(false); JarURLConnection.setUseFastExceptions(false);
......
...@@ -252,8 +252,7 @@ public class Binder { ...@@ -252,8 +252,7 @@ public class Binder {
} }
private <T> Object bindObject(ConfigurationPropertyName name, Bindable<T> target, private <T> Object bindObject(ConfigurationPropertyName name, Bindable<T> target,
BindHandler handler, Context context, boolean allowRecursiveBinding) BindHandler handler, Context context, boolean allowRecursiveBinding) {
throws Exception {
ConfigurationProperty property = findProperty(name, context); ConfigurationProperty property = findProperty(name, context);
if (property == null && containsNoDescendantOf(context.streamSources(), name)) { if (property == null && containsNoDescendantOf(context.streamSources(), name)) {
return null; return null;
......
...@@ -414,7 +414,7 @@ public class CollectionBinderTests { ...@@ -414,7 +414,7 @@ public class CollectionBinderTests {
this.sources.add(source); this.sources.add(source);
Bindable<ClonedArrayBean> target = Bindable.of(ClonedArrayBean.class); Bindable<ClonedArrayBean> target = Bindable.of(ClonedArrayBean.class);
ClonedArrayBean bean = this.binder.bind("foo", target).get(); ClonedArrayBean bean = this.binder.bind("foo", target).get();
assertThat(bean.getBar()).contains("hello"); assertThat(bean.getBar()).containsExactly("hello");
} }
public static class ExampleCollectionBean { public static class ExampleCollectionBean {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment