diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java index c16e6ebb0e..62965ecf09 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java @@ -26,7 +26,6 @@ import java.util.function.Supplier; import org.reactivestreams.Publisher; import reactor.core.publisher.Mono; -import reactor.core.publisher.MonoSink; import reactor.core.scheduler.Schedulers; import org.springframework.boot.actuate.endpoint.InvalidEndpointRequestException; @@ -234,17 +233,7 @@ public abstract class AbstractWebFluxEndpointHandlerMapping extends RequestMappi @Override public Object invoke(InvocationContext context) { - return Mono.create((sink) -> Schedulers.elastic().schedule(() -> invoke(context, sink))); - } - - private void invoke(InvocationContext context, MonoSink sink) { - try { - Object result = this.invoker.invoke(context); - sink.success(result); - } - catch (Exception ex) { - sink.error(ex); - } + return Mono.fromCallable(() -> this.invoker.invoke(context)).subscribeOn(Schedulers.elastic()); } } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthIndicatorReactiveAdapter.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthIndicatorReactiveAdapter.java index e3c38af47d..8dac711837 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthIndicatorReactiveAdapter.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthIndicatorReactiveAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ package org.springframework.boot.actuate.health; import reactor.core.publisher.Mono; -import reactor.core.publisher.MonoSink; import reactor.core.scheduler.Schedulers; import org.springframework.util.Assert; @@ -40,17 +39,7 @@ public class HealthIndicatorReactiveAdapter implements ReactiveHealthIndicator { @Override public Mono health() { - return Mono.create((sink) -> Schedulers.elastic().schedule(() -> invoke(sink))); - } - - private void invoke(MonoSink sink) { - try { - Health health = this.delegate.health(); - sink.success(health); - } - catch (Exception ex) { - sink.error(ex); - } + return Mono.fromCallable(this.delegate::health).subscribeOn(Schedulers.elastic()); } }