From 44299bb9808d0dc21a9bfc1c0c47e1539e00856d Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Thu, 30 Nov 2017 01:12:35 +0900 Subject: [PATCH] Polish Closes gh-11206 --- .../export/datadog/DatadogProperties.java | 2 +- .../export/influx/InfluxProperties.java | 2 +- .../DataSourcePoolMetricsConfiguration.java | 3 ++- .../appendix-application-properties.adoc | 23 ++++++++++--------- .../boot/loader/tools/Layouts.java | 7 +++--- .../boot/loader/PropertiesLauncher.java | 3 ++- .../config/ConfigFileApplicationListener.java | 4 ++-- 7 files changed, 24 insertions(+), 20 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/datadog/DatadogProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/datadog/DatadogProperties.java index 2d428e0aad..9e4680dff0 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/datadog/DatadogProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/datadog/DatadogProperties.java @@ -35,7 +35,7 @@ public class DatadogProperties extends StepRegistryProperties { /** * Tag that will be mapped to "host" when shipping metrics to Datadog. Can be - * omitted of host should be omitted on publishing. + * omitted if host should be omitted on publishing. */ private String hostTag; diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxProperties.java index e3d364af52..982898891a 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxProperties.java @@ -32,7 +32,7 @@ public class InfluxProperties extends StepRegistryProperties { /** * Tag that will be mapped to "host" when shipping metrics to Influx. Can be - * omitted of host should be omitted on publishing. + * omitted if host should be omitted on publishing. */ private String db; diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/jdbc/DataSourcePoolMetricsConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/jdbc/DataSourcePoolMetricsConfiguration.java index 4f882f1d6c..a0eab7a213 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/jdbc/DataSourcePoolMetricsConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/jdbc/DataSourcePoolMetricsConfiguration.java @@ -33,6 +33,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.jdbc.metadata.DataSourcePoolMetadataProvider; import org.springframework.context.annotation.Configuration; +import org.springframework.util.StringUtils; /** * Configure metrics for all available {@link DataSource datasources}. @@ -80,7 +81,7 @@ public class DataSourcePoolMetricsConfiguration { */ private String getDataSourceName(String beanName) { if (beanName.length() > DATASOURCE_SUFFIX.length() - && beanName.toLowerCase().endsWith(DATASOURCE_SUFFIX.toLowerCase())) { + && StringUtils.endsWithIgnoreCase(beanName, DATASOURCE_SUFFIX)) { return beanName.substring(0, beanName.length() - DATASOURCE_SUFFIX.length()); } return beanName; 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 c1dbdb7e1d..b2ca144038 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 @@ -1250,21 +1250,22 @@ content into your application. Rather, pick only the properties that you need. spring.metrics.export.atlas.config-time-to-live= # Time to live for subscriptions from the LWC service. spring.metrics.export.atlas.config-uri= # URI for the Atlas LWC endpoint to retrieve current subscriptions. spring.metrics.export.atlas.connect-timeout= # Connection timeout for requests to the backend. - spring.metrics.export.atlas.enabled= # Whether exporting of metrics to Atlas is enabled. + spring.metrics.export.atlas.enabled= # Whether exporting of metrics to this backend is enabled. spring.metrics.export.atlas.eval-uri= # URI for the Atlas LWC endpoint to evaluate the data for a subscription. spring.metrics.export.atlas.lwc-enabled= # Enable streaming to Atlas LWC. spring.metrics.export.atlas.meter-time-to-live= # Time to live for meters that do not have any activity. After this period the meter will be considered expired and will not get reported. spring.metrics.export.atlas.num-threads= # Number of threads to use with the metrics publishing scheduler. spring.metrics.export.atlas.read-timeout= # Read timeout for requests to the backend. - spring.metrics.export.atlas.step=1 # Step size (i.e. reporting frequency) to use. + spring.metrics.export.atlas.step=1m # Step size (i.e. reporting frequency) to use. spring.metrics.export.atlas.uri= # URI of the Atlas server. spring.metrics.export.datadog.api-key= # Datadog API key. spring.metrics.export.datadog.batch-size= # Number of measurements per request to use for the backend. If more measurements are found, then multiple requests will be made. spring.metrics.export.datadog.connect-timeout= # Connection timeout for requests to the backend. - spring.metrics.export.datadog.enabled= # Enable publishing to the backend. + spring.metrics.export.datadog.enabled= # Whether exporting of metrics to this backend is enabled. + spring.metrics.export.datadog.host-tag= # Tag that will be mapped to "host" when shipping metrics to Datadog. Can be omitted if host should be omitted on publishing. spring.metrics.export.datadog.num-threads= # Number of threads to use with the metrics publishing scheduler. spring.metrics.export.datadog.read-timeout= # Read timeout for requests to the backend. - spring.metrics.export.datadog.step=1 # Step size (i.e. reporting frequency) to use. + spring.metrics.export.datadog.step=1m # Step size (i.e. reporting frequency) to use. spring.metrics.export.datadog.uri= # URI to ship metrics to. If you need to publish metrics to an internal proxy en-route to Datadog, you can define the location of the proxy with this. spring.metrics.export.ganglia.addressing-mode= # UDP addressing mode, either unicast or multicast. spring.metrics.export.ganglia.duration-units= # Base time unit used to report durations. @@ -1286,13 +1287,13 @@ content into your application. Rather, pick only the properties that you need. spring.metrics.export.influx.compressed= # Enable GZIP compression of metrics batches published to Influx. spring.metrics.export.influx.connect-timeout= # Connection timeout for requests to the backend. spring.metrics.export.influx.consistency= # Write consistency for each point. - spring.metrics.export.influx.db= # Tag that will be mapped to "host" when shipping metrics to Influx. Can be omitted of host should be omitted on publishing. - spring.metrics.export.influx.enabled= # Whether exporting of metrics to InfluxDB is enabled. + spring.metrics.export.influx.db= # Tag that will be mapped to "host" when shipping metrics to Influx. Can be omitted if host should be omitted on publishing. + spring.metrics.export.influx.enabled= # Whether exporting of metrics to this backend is enabled. spring.metrics.export.influx.num-threads= # Number of threads to use with the metrics publishing scheduler. spring.metrics.export.influx.password= # Login password of the Influx server. spring.metrics.export.influx.read-timeout= # Read timeout for requests to the backend. spring.metrics.export.influx.retention-policy= # Retention policy to use (Influx writes to the DEFAULT retention policy if one is not specified). - spring.metrics.export.influx.step=1 # Step size (i.e. reporting frequency) to use. + spring.metrics.export.influx.step=1m # Step size (i.e. reporting frequency) to use. spring.metrics.export.influx.uri= # URI of the Influx server. spring.metrics.export.influx.user-name= # Login user of the Influx server. spring.metrics.export.prometheus.descriptions= # Enable publishing descriptions as part of the scrape payload to Prometheus. Turn this off to minimize the amount of data sent on each scrape. @@ -1300,14 +1301,14 @@ content into your application. Rather, pick only the properties that you need. spring.metrics.export.prometheus.step= # Step size (i.e. reporting frequency) to use. spring.metrics.export.simple.enabled=false # Whether exporting of metrics to a simple in-memory store is enabled. spring.metrics.export.simple.mode=cumulative # Counting mode. - spring.metrics.export.simple.step=10 # Step size (i.e. reporting frequency) to use. + spring.metrics.export.simple.step=10s # Step size (i.e. reporting frequency) to use. spring.metrics.export.statsd.enabled= # Export metrics to StatsD. - spring.metrics.export.statsd.flavor= # StatsD line protocol to use. + spring.metrics.export.statsd.flavor=datadog # StatsD line protocol to use. spring.metrics.export.statsd.host=localhost # Host of the StatsD server to receive exported metrics. spring.metrics.export.statsd.max-packet-length=1400 # Total length of a single payload should be kept within your network's MTU. - spring.metrics.export.statsd.polling-frequency=10 # How often gauges will be polled. When a gauge is polled, its value is recalculated and if the value has changed, it is sent to the StatsD server. + spring.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, it is sent to the StatsD server. spring.metrics.export.statsd.port=8125 # Port of the StatsD server to receive exported metrics. - spring.metrics.export.statsd.queue-size= # Maximum size of the queue of items waiting to be sent to the StatsD server. + spring.metrics.export.statsd.queue-size=2147483647 # Maximum size of the queue of items waiting to be sent to the StatsD server. spring.metrics.jdbc.datasource-metric-name=data.source # Name of the metric for data source usage. spring.metrics.jdbc.instrument-datasource=true # Instrument all available data sources. spring.metrics.web.client.record-request-percentiles=false # Whether instrumented requests record percentiles histogram buckets by default. diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Layouts.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Layouts.java index 78e5e44371..3efcb2c988 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Layouts.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Layouts.java @@ -42,13 +42,14 @@ public final class Layouts { if (file == null) { throw new IllegalArgumentException("File must not be null"); } - if (file.getName().toLowerCase().endsWith(".jar")) { + String lowerCaseFileName = file.getName().toLowerCase(); + if (lowerCaseFileName.endsWith(".jar")) { return new Jar(); } - if (file.getName().toLowerCase().endsWith(".war")) { + if (lowerCaseFileName.endsWith(".war")) { return new War(); } - if (file.isDirectory() || file.getName().toLowerCase().endsWith(".zip")) { + if (file.isDirectory() || lowerCaseFileName.endsWith(".zip")) { return new Expanded(); } throw new IllegalStateException("Unable to deduce layout for '" + file + "'"); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java index 6e98d7910c..7b49a0ac13 100755 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java @@ -555,7 +555,8 @@ public class PropertiesLauncher extends Launcher { if (path.startsWith("./")) { path = path.substring(2); } - if (path.toLowerCase().endsWith(".jar") || path.toLowerCase().endsWith(".zip")) { + String lowerCasePath = path.toLowerCase(); + if (lowerCasePath.endsWith(".jar") || lowerCasePath.endsWith(".zip")) { return path; } if (path.endsWith("/*")) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java index a3fbcc59be..a1084bdf2e 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java @@ -422,8 +422,8 @@ public class ConfigFileApplicationListener } private boolean canLoadFileExtension(PropertySourceLoader loader, String name) { - return Arrays.stream(loader.getFileExtensions()).map(String::toLowerCase) - .anyMatch(name.toLowerCase()::endsWith); + return Arrays.stream(loader.getFileExtensions()).anyMatch( + fileExtension -> StringUtils.endsWithIgnoreCase(name, fileExtension)); } private void loadForFileExtension(PropertySourceLoader loader, Profile profile,