Upgrade to Coroutines 1.3.0-RC
This commit upgrades Coroutines support to kotlinx.coroutines 1.3.0-RC, leverages the new Coroutines BOM and refine Coroutines detection to avoid false positives. Only Coroutines to Mono context interoperability is supported for now. CLoses gh-23326
This commit is contained in:
@@ -47,7 +47,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
*
|
||||
* <p>By default, depending on classpath availability, adapters are registered
|
||||
* for Reactor, RxJava 1, RxJava 2 types, {@link CompletableFuture}, Java 9+
|
||||
* {@code Flow.Publisher} and Kotlin Coroutines {@code Deferred}.
|
||||
* {@code Flow.Publisher} and Kotlin Coroutines {@code Deferred} and {@code Flow}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Sebastien Deleuze
|
||||
@@ -97,13 +97,9 @@ public class ReactiveAdapterRegistry {
|
||||
// We can fall back on "reactive-streams-flow-bridge" (once released)
|
||||
|
||||
// Coroutines
|
||||
if (this.reactorPresent && ClassUtils.isPresent("kotlinx.coroutines.Deferred", classLoader)) {
|
||||
if (this.reactorPresent && ClassUtils.isPresent("kotlinx.coroutines.reactor.MonoKt", classLoader) && ClassUtils.isPresent("kotlinx.coroutines.reactive.flow.PublisherAsFlowKt", classLoader)) {
|
||||
new CoroutinesRegistrar().registerAdapters(this);
|
||||
}
|
||||
// TODO Use a single CoroutinesRegistrar when Flow will be not experimental anymore
|
||||
if (this.reactorPresent && ClassUtils.isPresent("kotlinx.coroutines.flow.Flow", classLoader)) {
|
||||
new CoroutinesFlowRegistrar().registerAdapters(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -353,13 +349,7 @@ public class ReactiveAdapterRegistry {
|
||||
() -> CompletableDeferredKt.CompletableDeferred(null)),
|
||||
source -> CoroutinesUtils.deferredToMono((Deferred<?>) source),
|
||||
source -> CoroutinesUtils.monoToDeferred(Mono.from(source)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class CoroutinesFlowRegistrar {
|
||||
|
||||
void registerAdapters(ReactiveAdapterRegistry registry) {
|
||||
registry.registerReactiveType(
|
||||
ReactiveTypeDescriptor.multiValue(kotlinx.coroutines.flow.Flow.class, FlowKt::emptyFlow),
|
||||
source -> FlowAsPublisherKt.from((kotlinx.coroutines.flow.Flow<?>) source),
|
||||
@@ -367,5 +357,4 @@ public class ReactiveAdapterRegistry {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user