Update to Coroutine 1.3.0-RC2

This updates brings full interoperability between Reactor and
Coroutines contexts.

Closes gh-22986
This commit is contained in:
Sebastien Deleuze 2019-08-14 11:07:11 +02:00
parent 19ed439e4b
commit 4d10249b70
7 changed files with 11 additions and 14 deletions

View File

@ -31,7 +31,7 @@ ext {
}
aspectjVersion = "1.9.4"
coroutinesVersion = "1.3.0-RC"
coroutinesVersion = "1.3.0-RC2"
freemarkerVersion = "2.3.28"
groovyVersion = "2.5.7"
hsqldbVersion = "2.5.0"

View File

@ -24,7 +24,7 @@ import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.async
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.reactive.awaitFirstOrNull
import kotlinx.coroutines.reactive.flow.asPublisher
import kotlinx.coroutines.reactor.asFlux
import kotlinx.coroutines.reactor.mono
import reactor.core.publisher.Mono
@ -68,7 +68,7 @@ internal fun invokeHandlerMethod(method: Method, bean: Any, vararg args: Any?):
.let { if (it == Unit) null else it }
}.onErrorMap(InvocationTargetException::class.java) { it.targetException }
if (function.returnType.classifier == Flow::class) {
mono.flatMapMany { (it as Flow<Any>).asPublisher() }
mono.flatMapMany { (it as Flow<Any>).asFlux() }
}
else {
mono

View File

@ -28,9 +28,6 @@ import io.reactivex.BackpressureStrategy;
import io.reactivex.Flowable;
import kotlinx.coroutines.CompletableDeferredKt;
import kotlinx.coroutines.Deferred;
import kotlinx.coroutines.flow.FlowKt;
import kotlinx.coroutines.reactive.flow.FlowAsPublisherKt;
import kotlinx.coroutines.reactive.flow.PublisherAsFlowKt;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@ -97,7 +94,7 @@ public class ReactiveAdapterRegistry {
// We can fall back on "reactive-streams-flow-bridge" (once released)
// Coroutines
if (this.reactorPresent && ClassUtils.isPresent("kotlinx.coroutines.reactor.MonoKt", classLoader) && ClassUtils.isPresent("kotlinx.coroutines.reactive.flow.PublisherAsFlowKt", classLoader)) {
if (this.reactorPresent && ClassUtils.isPresent("kotlinx.coroutines.reactor.MonoKt", classLoader)) {
new CoroutinesRegistrar().registerAdapters(this);
}
}
@ -351,9 +348,9 @@ public class ReactiveAdapterRegistry {
source -> CoroutinesUtils.monoToDeferred(Mono.from(source)));
registry.registerReactiveType(
ReactiveTypeDescriptor.multiValue(kotlinx.coroutines.flow.Flow.class, FlowKt::emptyFlow),
source -> FlowAsPublisherKt.from((kotlinx.coroutines.flow.Flow<?>) source),
PublisherAsFlowKt::from
ReactiveTypeDescriptor.multiValue(kotlinx.coroutines.flow.Flow.class, kotlinx.coroutines.flow.FlowKt::emptyFlow),
source -> kotlinx.coroutines.reactor.FlowKt.asFlux((kotlinx.coroutines.flow.Flow<?>) source),
kotlinx.coroutines.reactive.FlowKt::asFlow
);
}
}

View File

@ -21,7 +21,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.reactive.awaitFirstOrNull
import kotlinx.coroutines.reactive.awaitSingle
import kotlinx.coroutines.reactive.flow.asFlow
import kotlinx.coroutines.reactive.asFlow
import org.reactivestreams.Publisher
import org.springframework.core.ParameterizedTypeReference
import reactor.core.publisher.Flux

View File

@ -20,7 +20,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.reactive.awaitFirstOrNull
import kotlinx.coroutines.reactive.awaitSingle
import kotlinx.coroutines.reactive.flow.asFlow
import kotlinx.coroutines.reactive.asFlow
import org.springframework.core.ParameterizedTypeReference
import org.springframework.http.ResponseEntity
import reactor.core.publisher.Flux

View File

@ -19,7 +19,7 @@ package org.springframework.web.reactive.function.client
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.reactive.awaitSingle
import kotlinx.coroutines.reactive.flow.asFlow
import kotlinx.coroutines.reactive.asFlow
import org.reactivestreams.Publisher
import org.springframework.core.ParameterizedTypeReference
import org.springframework.web.reactive.function.client.WebClient.RequestBodySpec

View File

@ -20,7 +20,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.reactive.awaitFirstOrNull
import kotlinx.coroutines.reactive.awaitSingle
import kotlinx.coroutines.reactive.flow.asFlow
import kotlinx.coroutines.reactive.asFlow
import org.springframework.core.ParameterizedTypeReference
import org.springframework.http.codec.multipart.Part
import org.springframework.util.MultiValueMap