Skip to content

Commit 3afbe84

Browse files
committed
Add more nullability annotations to module/spring-boot-amqp
See gh-46587
1 parent 81c0bfb commit 3afbe84

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/health/reactivehealthindicators/MyReactiveHealthIndicator.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ class MyReactiveHealthIndicator : ReactiveHealthIndicator {
2626

2727
override fun health(): Mono<Health> {
2828
// @formatter:off
29-
return doHealthCheck()!!.onErrorResume { exception: Throwable? ->
29+
return doHealthCheck().onErrorResume { exception: Throwable ->
3030
Mono.just(Health.Builder().down(exception).build())
3131
}
3232
// @formatter:on
3333
}
3434

35-
private fun doHealthCheck(): Mono<Health>? {
35+
private fun doHealthCheck(): Mono<Health> {
3636
// perform some specific health check
37-
return /**/ null
37+
return /**/ Mono.empty()
3838
}
3939

4040
}

module/spring-boot-amqp/src/main/java/org/springframework/boot/amqp/health/RabbitHealthIndicator.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ public RabbitHealthIndicator(RabbitTemplate rabbitTemplate) {
4343

4444
@Override
4545
protected void doHealthCheck(Health.Builder builder) throws Exception {
46-
builder.up().withDetail("version", getVersion());
46+
builder.up();
47+
String version = getVersion();
48+
if (version != null) {
49+
builder.withDetail("version", version);
50+
}
4751
}
4852

4953
private @Nullable String getVersion() {

0 commit comments

Comments
 (0)