Commit a3f3de22 authored by Phillip Webb's avatar Phillip Webb

Polish

parent 644ae2c2
...@@ -105,8 +105,7 @@ public class HealthIndicatorAutoConfiguration { ...@@ -105,8 +105,7 @@ public class HealthIndicatorAutoConfiguration {
private final HealthIndicatorProperties properties; private final HealthIndicatorProperties properties;
public HealthIndicatorAutoConfiguration( public HealthIndicatorAutoConfiguration(HealthIndicatorProperties properties) {
HealthIndicatorProperties properties) {
this.properties = properties; this.properties = properties;
} }
......
...@@ -35,8 +35,8 @@ public class EhCacheStatisticsProvider implements CacheStatisticsProvider<EhCach ...@@ -35,8 +35,8 @@ public class EhCacheStatisticsProvider implements CacheStatisticsProvider<EhCach
DefaultCacheStatistics statistics = new DefaultCacheStatistics(); DefaultCacheStatistics statistics = new DefaultCacheStatistics();
StatisticsGateway ehCacheStatistics = cache.getNativeCache().getStatistics(); StatisticsGateway ehCacheStatistics = cache.getNativeCache().getStatistics();
statistics.setSize(ehCacheStatistics.getSize()); statistics.setSize(ehCacheStatistics.getSize());
Double hitRatio = cacheHitRatio(ehCacheStatistics); double hitRatio = cacheHitRatio(ehCacheStatistics);
if (!hitRatio.isNaN()) { if (!Double.isNaN(hitRatio)) {
// ratio is calculated 'racily' and can drift marginally above unity, // ratio is calculated 'racily' and can drift marginally above unity,
// so we cap it here // so we cap it here
double sanitizedHitRatio = (hitRatio > 1 ? 1 : hitRatio); double sanitizedHitRatio = (hitRatio > 1 ? 1 : hitRatio);
...@@ -46,7 +46,7 @@ public class EhCacheStatisticsProvider implements CacheStatisticsProvider<EhCach ...@@ -46,7 +46,7 @@ public class EhCacheStatisticsProvider implements CacheStatisticsProvider<EhCach
return statistics; return statistics;
} }
private static Double cacheHitRatio(StatisticsGateway stats) { private double cacheHitRatio(StatisticsGateway stats) {
long hitCount = stats.cacheHitCount(); long hitCount = stats.cacheHitCount();
long cacheMissCount = stats.cacheMissCount(); long cacheMissCount = stats.cacheMissCount();
return ((double) hitCount) / (hitCount + cacheMissCount); return ((double) hitCount) / (hitCount + cacheMissCount);
......
...@@ -57,9 +57,11 @@ public class CouchbaseAutoConfiguration { ...@@ -57,9 +57,11 @@ public class CouchbaseAutoConfiguration {
@Bean @Bean
@ConditionalOnBean(Validator.class) @ConditionalOnBean(Validator.class)
public ValidatingCouchbaseEventListener validationEventListener(Validator validator) { public ValidatingCouchbaseEventListener validationEventListener(
Validator validator) {
return new ValidatingCouchbaseEventListener(validator); return new ValidatingCouchbaseEventListener(validator);
} }
} }
@Configuration @Configuration
......
...@@ -74,8 +74,8 @@ public class ProjectInfoAutoConfiguration { ...@@ -74,8 +74,8 @@ public class ProjectInfoAutoConfiguration {
protected void bindPropertiesTo(Object target, Resource location, String prefix) protected void bindPropertiesTo(Object target, Resource location, String prefix)
throws BindException, IOException { throws BindException, IOException {
PropertiesConfigurationFactory<Object> factory = PropertiesConfigurationFactory<Object> factory = new PropertiesConfigurationFactory<Object>(
new PropertiesConfigurationFactory<Object>(target); target);
factory.setConversionService(this.conversionService); factory.setConversionService(this.conversionService);
factory.setTargetName(prefix); factory.setTargetName(prefix);
Properties gitInfoProperties = PropertiesLoaderUtils.loadProperties(location); Properties gitInfoProperties = PropertiesLoaderUtils.loadProperties(location);
...@@ -89,7 +89,6 @@ public class ProjectInfoAutoConfiguration { ...@@ -89,7 +89,6 @@ public class ProjectInfoAutoConfiguration {
return conversionService; return conversionService;
} }
static class GitResourceAvailableCondition extends SpringBootCondition { static class GitResourceAvailableCondition extends SpringBootCondition {
private final ResourceLoader defaultResourceLoader = new DefaultResourceLoader(); private final ResourceLoader defaultResourceLoader = new DefaultResourceLoader();
...@@ -125,7 +124,8 @@ public class ProjectInfoAutoConfiguration { ...@@ -125,7 +124,8 @@ public class ProjectInfoAutoConfiguration {
if (epoch != null) { if (epoch != null) {
return new Date(epoch); return new Date(epoch);
} }
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX", Locale.US); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX",
Locale.US);
try { try {
return format.parse(s); return format.parse(s);
} }
...@@ -145,10 +145,11 @@ public class ProjectInfoAutoConfiguration { ...@@ -145,10 +145,11 @@ public class ProjectInfoAutoConfiguration {
try { try {
return Long.parseLong(s) * 1000; return Long.parseLong(s) * 1000;
} }
catch (NumberFormatException e) { catch (NumberFormatException ex) {
return null; return null;
} }
} }
} }
} }
...@@ -64,7 +64,8 @@ public class CouchbaseRepositoriesAutoConfigurationTests { ...@@ -64,7 +64,8 @@ public class CouchbaseRepositoriesAutoConfigurationTests {
@Test @Test
public void disableRepository() { public void disableRepository() {
load(DefaultConfiguration.class, "spring.data.couchbase.repositories.enabled=false"); load(DefaultConfiguration.class,
"spring.data.couchbase.repositories.enabled=false");
assertThat(this.context.getBeansOfType(CityRepository.class)).hasSize(0); assertThat(this.context.getBeansOfType(CityRepository.class)).hasSize(0);
} }
...@@ -87,14 +88,12 @@ public class CouchbaseRepositoriesAutoConfigurationTests { ...@@ -87,14 +88,12 @@ public class CouchbaseRepositoriesAutoConfigurationTests {
this.context = context; this.context = context;
} }
@Configuration @Configuration
@TestAutoConfigurationPackage(City.class) @TestAutoConfigurationPackage(City.class)
static class CouchbaseNotAvailableConfiguration { static class CouchbaseNotAvailableConfiguration {
} }
@Configuration @Configuration
@TestAutoConfigurationPackage(City.class) @TestAutoConfigurationPackage(City.class)
@Import(CouchbaseTestConfiguration.class) @Import(CouchbaseTestConfiguration.class)
......
...@@ -86,7 +86,6 @@ public class ProjectInfoAutoConfigurationTests { ...@@ -86,7 +86,6 @@ public class ProjectInfoAutoConfigurationTests {
assertThat(gitInfo).isSameAs(this.context.getBean("customGitInfo")); assertThat(gitInfo).isSameAs(this.context.getBean("customGitInfo"));
} }
private void load(String... environment) { private void load(String... environment) {
load(null, environment); load(null, environment);
} }
......
...@@ -438,6 +438,7 @@ in the '`Spring Boot features`' section, or the ...@@ -438,6 +438,7 @@ in the '`Spring Boot features`' section, or the
code. code.
[[howto-user-a-random-unassigned-http-port]] [[howto-user-a-random-unassigned-http-port]]
=== Use a random unassigned HTTP port === Use a random unassigned HTTP port
To scan for a free port (using OS natives to prevent clashes) use `server.port=0`. To scan for a free port (using OS natives to prevent clashes) use `server.port=0`.
...@@ -507,6 +508,8 @@ the two to configure programmatically. See the ...@@ -507,6 +508,8 @@ the two to configure programmatically. See the
{github-code}/spring-boot-samples/spring-boot-sample-tomcat-multi-connectors[`spring-boot-sample-tomcat-multi-connectors`] {github-code}/spring-boot-samples/spring-boot-sample-tomcat-multi-connectors[`spring-boot-sample-tomcat-multi-connectors`]
sample project for an example. sample project for an example.
[[howto-configure-accesslogs]] [[howto-configure-accesslogs]]
=== Configure Access Logging === Configure Access Logging
Access logs can be configured for Tomcat and Undertow via their respective namespaces. Access logs can be configured for Tomcat and Undertow via their respective namespaces.
...@@ -538,6 +541,7 @@ Logs are stored in a `logs` directory relative to the working directory of the ...@@ -538,6 +541,7 @@ Logs are stored in a `logs` directory relative to the working directory of the
application. This can be customized via `server.undertow.accesslog.directory`. application. This can be customized via `server.undertow.accesslog.directory`.
[[howto-use-behind-a-proxy-server]] [[howto-use-behind-a-proxy-server]]
[[howto-use-tomcat-behind-a-proxy-server]] [[howto-use-tomcat-behind-a-proxy-server]]
=== Use behind a front-end proxy server === Use behind a front-end proxy server
......
...@@ -344,7 +344,6 @@ public class TomcatEmbeddedServletContainerFactoryTests ...@@ -344,7 +344,6 @@ public class TomcatEmbeddedServletContainerFactoryTests
public void startupFailureDoesNotResultInUnstoppedThreadsBeingReported() public void startupFailureDoesNotResultInUnstoppedThreadsBeingReported()
throws IOException { throws IOException {
super.portClashOfPrimaryConnectorResultsInPortInUseException(); super.portClashOfPrimaryConnectorResultsInPortInUseException();
String string = this.outputCapture.toString(); String string = this.outputCapture.toString();
assertThat(string) assertThat(string)
.doesNotContain("appears to have started a thread named [main]"); .doesNotContain("appears to have started a thread named [main]");
......
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