Skip to content

Commit 4d10249

Browse files
committed
Update to Coroutine 1.3.0-RC2
This updates brings full interoperability between Reactor and Coroutines contexts. Closes gh-22986
1 parent 19ed439 commit 4d10249

File tree

7 files changed

+11
-14
lines changed

7 files changed

+11
-14
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ ext {
3131
}
3232

3333
aspectjVersion = "1.9.4"
34-
coroutinesVersion = "1.3.0-RC"
34+
coroutinesVersion = "1.3.0-RC2"
3535
freemarkerVersion = "2.3.28"
3636
groovyVersion = "2.5.7"
3737
hsqldbVersion = "2.5.0"

spring-core-coroutines/src/main/kotlin/org/springframework/core/CoroutinesUtils.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import kotlinx.coroutines.GlobalScope
2424
import kotlinx.coroutines.async
2525
import kotlinx.coroutines.flow.Flow
2626
import kotlinx.coroutines.reactive.awaitFirstOrNull
27-
import kotlinx.coroutines.reactive.flow.asPublisher
27+
import kotlinx.coroutines.reactor.asFlux
2828

2929
import kotlinx.coroutines.reactor.mono
3030
import reactor.core.publisher.Mono
@@ -68,7 +68,7 @@ internal fun invokeHandlerMethod(method: Method, bean: Any, vararg args: Any?):
6868
.let { if (it == Unit) null else it }
6969
}.onErrorMap(InvocationTargetException::class.java) { it.targetException }
7070
if (function.returnType.classifier == Flow::class) {
71-
mono.flatMapMany { (it as Flow<Any>).asPublisher() }
71+
mono.flatMapMany { (it as Flow<Any>).asFlux() }
7272
}
7373
else {
7474
mono

spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java

+4-7
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
import io.reactivex.Flowable;
2929
import kotlinx.coroutines.CompletableDeferredKt;
3030
import kotlinx.coroutines.Deferred;
31-
import kotlinx.coroutines.flow.FlowKt;
32-
import kotlinx.coroutines.reactive.flow.FlowAsPublisherKt;
33-
import kotlinx.coroutines.reactive.flow.PublisherAsFlowKt;
3431
import org.reactivestreams.Publisher;
3532
import reactor.core.publisher.Flux;
3633
import reactor.core.publisher.Mono;
@@ -97,7 +94,7 @@ public ReactiveAdapterRegistry() {
9794
// We can fall back on "reactive-streams-flow-bridge" (once released)
9895

9996
// Coroutines
100-
if (this.reactorPresent && ClassUtils.isPresent("kotlinx.coroutines.reactor.MonoKt", classLoader) && ClassUtils.isPresent("kotlinx.coroutines.reactive.flow.PublisherAsFlowKt", classLoader)) {
97+
if (this.reactorPresent && ClassUtils.isPresent("kotlinx.coroutines.reactor.MonoKt", classLoader)) {
10198
new CoroutinesRegistrar().registerAdapters(this);
10299
}
103100
}
@@ -351,9 +348,9 @@ void registerAdapters(ReactiveAdapterRegistry registry) {
351348
source -> CoroutinesUtils.monoToDeferred(Mono.from(source)));
352349

353350
registry.registerReactiveType(
354-
ReactiveTypeDescriptor.multiValue(kotlinx.coroutines.flow.Flow.class, FlowKt::emptyFlow),
355-
source -> FlowAsPublisherKt.from((kotlinx.coroutines.flow.Flow<?>) source),
356-
PublisherAsFlowKt::from
351+
ReactiveTypeDescriptor.multiValue(kotlinx.coroutines.flow.Flow.class, kotlinx.coroutines.flow.FlowKt::emptyFlow),
352+
source -> kotlinx.coroutines.reactor.FlowKt.asFlux((kotlinx.coroutines.flow.Flow<?>) source),
353+
kotlinx.coroutines.reactive.FlowKt::asFlow
357354
);
358355
}
359356
}

spring-messaging/src/main/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensions.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
2121
import kotlinx.coroutines.flow.Flow
2222
import kotlinx.coroutines.reactive.awaitFirstOrNull
2323
import kotlinx.coroutines.reactive.awaitSingle
24-
import kotlinx.coroutines.reactive.flow.asFlow
24+
import kotlinx.coroutines.reactive.asFlow
2525
import org.reactivestreams.Publisher
2626
import org.springframework.core.ParameterizedTypeReference
2727
import reactor.core.publisher.Flux

spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/ClientResponseExtensions.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
2020
import kotlinx.coroutines.flow.Flow
2121
import kotlinx.coroutines.reactive.awaitFirstOrNull
2222
import kotlinx.coroutines.reactive.awaitSingle
23-
import kotlinx.coroutines.reactive.flow.asFlow
23+
import kotlinx.coroutines.reactive.asFlow
2424
import org.springframework.core.ParameterizedTypeReference
2525
import org.springframework.http.ResponseEntity
2626
import reactor.core.publisher.Flux

spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/WebClientExtensions.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package org.springframework.web.reactive.function.client
1919
import kotlinx.coroutines.ExperimentalCoroutinesApi
2020
import kotlinx.coroutines.flow.Flow
2121
import kotlinx.coroutines.reactive.awaitSingle
22-
import kotlinx.coroutines.reactive.flow.asFlow
22+
import kotlinx.coroutines.reactive.asFlow
2323
import org.reactivestreams.Publisher
2424
import org.springframework.core.ParameterizedTypeReference
2525
import org.springframework.web.reactive.function.client.WebClient.RequestBodySpec

spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensions.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
2020
import kotlinx.coroutines.flow.Flow
2121
import kotlinx.coroutines.reactive.awaitFirstOrNull
2222
import kotlinx.coroutines.reactive.awaitSingle
23-
import kotlinx.coroutines.reactive.flow.asFlow
23+
import kotlinx.coroutines.reactive.asFlow
2424
import org.springframework.core.ParameterizedTypeReference
2525
import org.springframework.http.codec.multipart.Part
2626
import org.springframework.util.MultiValueMap

0 commit comments

Comments
 (0)