diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfiguration.java index d4f55274b2f..d69cc88a38d 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfiguration.java @@ -47,8 +47,8 @@ import org.springframework.context.annotation.Configuration; @ConditionalOnEnabledHealthIndicator("influxdb") @AutoConfigureBefore(HealthIndicatorAutoConfiguration.class) @AutoConfigureAfter(InfluxDbAutoConfiguration.class) -public class InfluxDbHealthIndicatorAutoConfiguration extends - CompositeHealthIndicatorConfiguration { +public class InfluxDbHealthIndicatorAutoConfiguration + extends CompositeHealthIndicatorConfiguration { private final Map influxDbs; diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfigurationTests.java index 743bc96d539..9796ac6ac5a 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfigurationTests.java @@ -38,10 +38,9 @@ import static org.mockito.Mockito.mock; public class InfluxDbHealthIndicatorAutoConfigurationTests { private ApplicationContextRunner contextRunner = new ApplicationContextRunner() - .withUserConfiguration(InfluxDbConfiguration.class) - .withConfiguration(AutoConfigurations.of( - InfluxDbHealthIndicatorAutoConfiguration.class, - HealthIndicatorAutoConfiguration.class)); + .withUserConfiguration(InfluxDbConfiguration.class).withConfiguration( + AutoConfigurations.of(InfluxDbHealthIndicatorAutoConfiguration.class, + HealthIndicatorAutoConfiguration.class)); @Test public void runShouldCreateIndicator() { @@ -52,9 +51,8 @@ public class InfluxDbHealthIndicatorAutoConfigurationTests { @Test public void runWhenDisabledShouldNotCreateIndicator() { - this.contextRunner - .withPropertyValues("management.health.influxdb.enabled:false").run( - (context) -> assertThat(context) + this.contextRunner.withPropertyValues("management.health.influxdb.enabled:false") + .run((context) -> assertThat(context) .doesNotHaveBean(InfluxDbHealthIndicator.class) .hasSingleBean(ApplicationHealthIndicator.class)); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/neo4j/Neo4jHealthIndicatorAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/neo4j/Neo4jHealthIndicatorAutoConfigurationTests.java index a8e3c77422f..a7d83705f44 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/neo4j/Neo4jHealthIndicatorAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/neo4j/Neo4jHealthIndicatorAutoConfigurationTests.java @@ -42,10 +42,9 @@ import static org.mockito.Mockito.mock; public class Neo4jHealthIndicatorAutoConfigurationTests { private ApplicationContextRunner contextRunner = new ApplicationContextRunner() - .withUserConfiguration(Neo4jConfiguration.class) - .withConfiguration(AutoConfigurations.of( - Neo4jHealthIndicatorAutoConfiguration.class, - HealthIndicatorAutoConfiguration.class)); + .withUserConfiguration(Neo4jConfiguration.class).withConfiguration( + AutoConfigurations.of(Neo4jHealthIndicatorAutoConfiguration.class, + HealthIndicatorAutoConfiguration.class)); @Test public void runShouldCreateIndicator() { @@ -64,9 +63,8 @@ public class Neo4jHealthIndicatorAutoConfigurationTests { @Test public void defaultIndicatorCanBeReplaced() { - this.contextRunner - .withUserConfiguration(CustomIndicatorConfiguration.class).run( - (context) -> { + this.contextRunner.withUserConfiguration(CustomIndicatorConfiguration.class) + .run((context) -> { assertThat(context).hasSingleBean(Neo4jHealthIndicator.class); assertThat(context).doesNotHaveBean(ApplicationHealthIndicator.class); Health health = context.getBean(Neo4jHealthIndicator.class).health(); @@ -90,12 +88,15 @@ public class Neo4jHealthIndicatorAutoConfigurationTests { @Bean public Neo4jHealthIndicator neo4jHealthIndicator(SessionFactory sessionFactory) { return new Neo4jHealthIndicator(sessionFactory) { + @Override protected void extractResult(Session session, Health.Builder builder) { builder.up().withDetail("test", true); } + }; } + } } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cassandra/CassandraHealthIndicator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cassandra/CassandraHealthIndicator.java index 0309b360b9f..584cd1668da 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cassandra/CassandraHealthIndicator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cassandra/CassandraHealthIndicator.java @@ -48,8 +48,7 @@ public class CassandraHealthIndicator extends AbstractHealthIndicator { @Override protected void doHealthCheck(Health.Builder builder) throws Exception { - Select select = QueryBuilder.select("release_version").from("system", - "local"); + Select select = QueryBuilder.select("release_version").from("system", "local"); ResultSet results = this.cassandraOperations.getCqlOperations() .queryForResultSet(select); if (results.isExhausted()) { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/couchbase/CouchbaseHealthIndicator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/couchbase/CouchbaseHealthIndicator.java index 3a8e52f149c..13beb6fec8e 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/couchbase/CouchbaseHealthIndicator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/couchbase/CouchbaseHealthIndicator.java @@ -16,10 +16,8 @@ package org.springframework.boot.actuate.couchbase; -import java.util.List; - import com.couchbase.client.java.bucket.BucketInfo; -import com.couchbase.client.java.util.features.Version; +import com.couchbase.client.java.cluster.ClusterInfo; import org.springframework.boot.actuate.health.AbstractHealthIndicator; import org.springframework.boot.actuate.health.Health; @@ -37,24 +35,21 @@ import org.springframework.util.StringUtils; */ public class CouchbaseHealthIndicator extends AbstractHealthIndicator { - private CouchbaseOperations couchbaseOperations; + private CouchbaseOperations operations; public CouchbaseHealthIndicator(CouchbaseOperations couchbaseOperations) { Assert.notNull(couchbaseOperations, "CouchbaseOperations must not be null"); - this.couchbaseOperations = couchbaseOperations; + this.operations = couchbaseOperations; } @Override protected void doHealthCheck(Health.Builder builder) throws Exception { - List versions = this.couchbaseOperations.getCouchbaseClusterInfo() - .getAllVersions(); - BucketInfo bucketInfo = this.couchbaseOperations.getCouchbaseBucket() - .bucketManager().info(); - builder.up() - .withDetail("versions", StringUtils.collectionToCommaDelimitedString( - versions)) - .withDetail("nodes", StringUtils.collectionToCommaDelimitedString( - bucketInfo.nodeList())); + ClusterInfo cluster = this.operations.getCouchbaseClusterInfo(); + BucketInfo bucket = this.operations.getCouchbaseBucket().bucketManager().info(); + String versions = StringUtils + .collectionToCommaDelimitedString(cluster.getAllVersions()); + String nodes = StringUtils.collectionToCommaDelimitedString(bucket.nodeList()); + builder.up().withDetail("versions", versions).withDetail("nodes", nodes); } } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/couchbase/CouchbaseHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/couchbase/CouchbaseHealthIndicatorTests.java index 833e7cd457b..516a514c7e3 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/couchbase/CouchbaseHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/couchbase/CouchbaseHealthIndicatorTests.java @@ -48,8 +48,8 @@ public class CouchbaseHealthIndicatorTests { @Test public void couchbaseIsUp() throws UnknownHostException { BucketInfo bucketInfo = mock(BucketInfo.class); - given(bucketInfo.nodeList()).willReturn(Collections.singletonList( - InetAddress.getByName("127.0.0.1"))); + given(bucketInfo.nodeList()).willReturn( + Collections.singletonList(InetAddress.getByName("127.0.0.1"))); BucketManager bucketManager = mock(BucketManager.class); given(bucketManager.info()).willReturn(bucketInfo); Bucket bucket = mock(Bucket.class); diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicatorTests.java index ff4a24d9680..4eb124056f1 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicatorTests.java @@ -55,8 +55,8 @@ public class InfluxDbHealthIndicatorTests { @Test public void influxDbIsDown() { InfluxDB influxDB = mock(InfluxDB.class); - given(influxDB.ping()).willThrow( - new InfluxDBException(new IOException("Connection failed"))); + given(influxDB.ping()) + .willThrow(new InfluxDBException(new IOException("Connection failed"))); InfluxDbHealthIndicator healthIndicator = new InfluxDbHealthIndicator(influxDB); Health health = healthIndicator.health(); assertThat(health.getStatus()).isEqualTo(Status.DOWN); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java index 52e8ea82c5e..4ca62d83d10 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java @@ -56,7 +56,7 @@ public class CassandraProperties { private String clusterName; /** - * Comma-separated list of cluster node addresses. + * Cluster node addresses. */ private final List contactPoints = new ArrayList<>( Collections.singleton("localhost"));