Skip to content

Commit eb4b0a3

Browse files
committed
Merge branch '2.6.x' into 2.7.x
Closes gh-32513
2 parents 9a004a6 + 1928177 commit eb4b0a3

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/couchbase/CouchbaseReactiveHealthIndicator.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.boot.actuate.couchbase;
1818

19-
import com.couchbase.client.core.diagnostics.DiagnosticsResult;
2019
import com.couchbase.client.java.Cluster;
2120
import reactor.core.publisher.Mono;
2221

@@ -46,9 +45,10 @@ public CouchbaseReactiveHealthIndicator(Cluster cluster) {
4645

4746
@Override
4847
protected Mono<Health> doHealthCheck(Health.Builder builder) {
49-
DiagnosticsResult diagnostics = this.cluster.diagnostics();
50-
new CouchbaseHealth(diagnostics).applyTo(builder);
51-
return Mono.just(builder.build());
48+
return this.cluster.reactive().diagnostics().map((diagnostics) -> {
49+
new CouchbaseHealth(diagnostics).applyTo(builder);
50+
return builder.build();
51+
});
5252
}
5353

5454
}

spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/couchbase/CouchbaseReactiveHealthIndicatorTests.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
import com.couchbase.client.core.endpoint.EndpointState;
2929
import com.couchbase.client.core.service.ServiceType;
3030
import com.couchbase.client.java.Cluster;
31+
import com.couchbase.client.java.ReactiveCluster;
3132
import org.junit.jupiter.api.Test;
33+
import reactor.core.publisher.Mono;
3234

3335
import org.springframework.boot.actuate.health.Health;
3436
import org.springframework.boot.actuate.health.Status;
@@ -53,13 +55,15 @@ void couchbaseClusterIsUp() {
5355
new EndpointDiagnostics(ServiceType.KV, EndpointState.CONNECTED, "127.0.0.1", "127.0.0.1",
5456
Optional.empty(), Optional.of(1234L), Optional.of("endpoint-1"), Optional.empty())));
5557
DiagnosticsResult diagnostics = new DiagnosticsResult(endpoints, "test-sdk", "test-id");
56-
given(cluster.diagnostics()).willReturn(diagnostics);
58+
ReactiveCluster reactiveCluster = mock(ReactiveCluster.class);
59+
given(reactiveCluster.diagnostics()).willReturn(Mono.just(diagnostics));
60+
given(cluster.reactive()).willReturn(reactiveCluster);
5761
Health health = healthIndicator.health().block(Duration.ofSeconds(30));
5862
assertThat(health.getStatus()).isEqualTo(Status.UP);
5963
assertThat(health.getDetails()).containsEntry("sdk", "test-sdk");
6064
assertThat(health.getDetails()).containsKey("endpoints");
6165
assertThat((List<Map<String, Object>>) health.getDetails().get("endpoints")).hasSize(1);
62-
then(cluster).should().diagnostics();
66+
then(reactiveCluster).should().diagnostics();
6367
}
6468

6569
@Test
@@ -74,13 +78,15 @@ void couchbaseClusterIsDown() {
7478
new EndpointDiagnostics(ServiceType.KV, EndpointState.CONNECTING, "127.0.0.1", "127.0.0.1",
7579
Optional.empty(), Optional.of(1234L), Optional.of("endpoint-2"), Optional.empty())));
7680
DiagnosticsResult diagnostics = new DiagnosticsResult(endpoints, "test-sdk", "test-id");
77-
given(cluster.diagnostics()).willReturn(diagnostics);
81+
ReactiveCluster reactiveCluster = mock(ReactiveCluster.class);
82+
given(reactiveCluster.diagnostics()).willReturn(Mono.just(diagnostics));
83+
given(cluster.reactive()).willReturn(reactiveCluster);
7884
Health health = healthIndicator.health().block(Duration.ofSeconds(30));
7985
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
8086
assertThat(health.getDetails()).containsEntry("sdk", "test-sdk");
8187
assertThat(health.getDetails()).containsKey("endpoints");
8288
assertThat((List<Map<String, Object>>) health.getDetails().get("endpoints")).hasSize(2);
83-
then(cluster).should().diagnostics();
89+
then(reactiveCluster).should().diagnostics();
8490
}
8591

8692
}

0 commit comments

Comments
 (0)