diff --git a/build.gradle b/build.gradle index 02d7703012..8bfebe9826 100644 --- a/build.gradle +++ b/build.gradle @@ -29,7 +29,7 @@ ext { } aspectjVersion = "1.9.4" - coroutinesVersion = "1.2.2" + coroutinesVersion = "1.3.0-M2" freemarkerVersion = "2.3.28" groovyVersion = "2.5.7" hsqldbVersion = "2.5.0" diff --git a/spring-core-coroutines/src/main/kotlin/org/springframework/core/CoroutinesUtils.kt b/spring-core-coroutines/src/main/kotlin/org/springframework/core/CoroutinesUtils.kt index 1f51b55aae..896b20bdd3 100644 --- a/spring-core-coroutines/src/main/kotlin/org/springframework/core/CoroutinesUtils.kt +++ b/spring-core-coroutines/src/main/kotlin/org/springframework/core/CoroutinesUtils.kt @@ -19,7 +19,7 @@ package org.springframework.core import kotlinx.coroutines.Deferred import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.FlowPreview +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.async import kotlinx.coroutines.flow.Flow @@ -59,7 +59,7 @@ internal fun monoToDeferred(source: Mono) = * @since 5.2 */ @Suppress("UNCHECKED_CAST") -@FlowPreview +@ExperimentalCoroutinesApi internal fun invokeHandlerMethod(method: Method, bean: Any, vararg args: Any?): Any? { val function = method.kotlinFunction!! return if (function.isSuspend) { diff --git a/spring-core/src/test/kotlin/org/springframework/core/KotlinReactiveAdapterRegistryTests.kt b/spring-core/src/test/kotlin/org/springframework/core/KotlinReactiveAdapterRegistryTests.kt index bbab749d88..be440fabd9 100644 --- a/spring-core/src/test/kotlin/org/springframework/core/KotlinReactiveAdapterRegistryTests.kt +++ b/spring-core/src/test/kotlin/org/springframework/core/KotlinReactiveAdapterRegistryTests.kt @@ -17,7 +17,7 @@ package org.springframework.core import kotlinx.coroutines.Deferred -import kotlinx.coroutines.FlowPreview +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.async import kotlinx.coroutines.flow.Flow @@ -35,6 +35,7 @@ import reactor.test.StepVerifier import java.time.Duration import kotlin.reflect.KClass +@ExperimentalCoroutinesApi class KotlinReactiveAdapterRegistryTests { private val registry = ReactiveAdapterRegistry.getSharedInstance() @@ -57,7 +58,6 @@ class KotlinReactiveAdapterRegistryTests { } @Test - @FlowPreview fun flowToPublisher() { val source = flow { emit(1) @@ -74,7 +74,6 @@ class KotlinReactiveAdapterRegistryTests { } @Test - @FlowPreview fun publisherToFlow() { val source = Flux.just(1, 2, 3) val target = getAdapter(Flow::class).fromPublisher(source) diff --git a/spring-messaging/src/main/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensions.kt b/spring-messaging/src/main/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensions.kt index db5b9ad48a..c60533743c 100644 --- a/spring-messaging/src/main/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensions.kt +++ b/spring-messaging/src/main/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensions.kt @@ -17,7 +17,7 @@ package org.springframework.messaging.rsocket import io.rsocket.transport.ClientTransport -import kotlinx.coroutines.FlowPreview +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.reactive.awaitFirstOrNull import kotlinx.coroutines.reactive.awaitSingle @@ -90,7 +90,7 @@ inline fun RSocketRequester.RequestSpec.dataWithType(publisher * @author Sebastien Deleuze * @since 5.2 */ -@FlowPreview +@ExperimentalCoroutinesApi inline fun RSocketRequester.RequestSpec.dataWithType(flow: Flow): RSocketRequester.ResponseSpec = data(flow, object : ParameterizedTypeReference() {}) @@ -120,9 +120,9 @@ suspend inline fun RSocketRequester.ResponseSpec.retrieveAndAw * @author Sebastien Deleuze * @since 5.2 */ -@FlowPreview -inline fun RSocketRequester.ResponseSpec.retrieveFlow(batchSize: Int = 1): Flow = - retrieveFlux(object : ParameterizedTypeReference() {}).asFlow(batchSize) +@ExperimentalCoroutinesApi +inline fun RSocketRequester.ResponseSpec.retrieveFlow(): Flow = + retrieveFlux(object : ParameterizedTypeReference() {}).asFlow() /** * Extension for [RSocketRequester.ResponseSpec.retrieveMono] providing a `retrieveMono()` diff --git a/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketClientToServerCoroutinesIntegrationTests.kt b/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketClientToServerCoroutinesIntegrationTests.kt index 23e64e3c3c..b32ce7a684 100644 --- a/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketClientToServerCoroutinesIntegrationTests.kt +++ b/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketClientToServerCoroutinesIntegrationTests.kt @@ -21,7 +21,7 @@ import io.rsocket.RSocketFactory import io.rsocket.frame.decoder.PayloadDecoder import io.rsocket.transport.netty.server.CloseableChannel import io.rsocket.transport.netty.server.TcpServerTransport -import kotlinx.coroutines.FlowPreview +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow @@ -49,6 +49,7 @@ import java.time.Duration * @author Sebastien Deleuze * @author Rossen Stoyanchev */ +@ExperimentalCoroutinesApi class RSocketClientToServerCoroutinesIntegrationTests { @Test @@ -104,7 +105,7 @@ class RSocketClientToServerCoroutinesIntegrationTests { .verify(Duration.ofSeconds(5)) } - @FlowPreview + @ExperimentalCoroutinesApi @Controller class ServerController { @@ -159,7 +160,7 @@ class RSocketClientToServerCoroutinesIntegrationTests { @Configuration open class ServerConfig { - @FlowPreview + @ExperimentalCoroutinesApi @Bean open fun controller(): ServerController { return ServerController() diff --git a/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensionsTests.kt b/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensionsTests.kt index 46f870e330..f1693f60c1 100644 --- a/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensionsTests.kt +++ b/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensionsTests.kt @@ -2,7 +2,7 @@ package org.springframework.messaging.rsocket import io.mockk.every import io.mockk.mockk -import kotlinx.coroutines.FlowPreview +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.toList import kotlinx.coroutines.runBlocking @@ -20,7 +20,7 @@ import java.util.concurrent.CompletableFuture * * @author Sebastien Deleuze */ -@FlowPreview +@ExperimentalCoroutinesApi class RSocketRequesterExtensionsTests { private val stringTypeRefMatcher: (ParameterizedTypeReference<*>) -> Boolean = { it.type == String::class.java } diff --git a/spring-test/src/main/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensions.kt b/spring-test/src/main/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensions.kt index e70ddee89c..8634b6f319 100644 --- a/spring-test/src/main/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensions.kt +++ b/spring-test/src/main/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensions.kt @@ -16,7 +16,7 @@ package org.springframework.test.web.reactive.server -import kotlinx.coroutines.FlowPreview +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import org.reactivestreams.Publisher import org.springframework.core.ParameterizedTypeReference @@ -70,7 +70,7 @@ inline fun RequestBodySpec.bodyWithType(publisher: Publisher RequestBodySpec.bodyWithType(flow: Flow): RequestHeadersSpec<*> = body(flow, object : ParameterizedTypeReference() {}) diff --git a/spring-test/src/test/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensionsTests.kt b/spring-test/src/test/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensionsTests.kt index 6432b95418..c984bed5ed 100644 --- a/spring-test/src/test/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensionsTests.kt +++ b/spring-test/src/test/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensionsTests.kt @@ -18,7 +18,7 @@ package org.springframework.test.web.reactive.server import io.mockk.mockk import io.mockk.verify -import kotlinx.coroutines.FlowPreview +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import org.junit.Assert.assertEquals import org.junit.Test @@ -47,7 +47,7 @@ class WebTestClientExtensionsTests { } @Test - @FlowPreview + @ExperimentalCoroutinesApi fun `RequestBodySpec#bodyWithType with Flow and reified type parameters`() { val body = mockk>() requestBodySpec.bodyWithType(body) diff --git a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/ClientResponseExtensions.kt b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/ClientResponseExtensions.kt index 3f9e9ed8bc..49d7ff32c8 100644 --- a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/ClientResponseExtensions.kt +++ b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/ClientResponseExtensions.kt @@ -16,7 +16,7 @@ package org.springframework.web.reactive.function.client -import kotlinx.coroutines.FlowPreview +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.reactive.awaitFirstOrNull import kotlinx.coroutines.reactive.awaitSingle @@ -51,15 +51,12 @@ inline fun ClientResponse.bodyToFlux(): Flux = /** * Coroutines [kotlinx.coroutines.flow.Flow] based variant of [ClientResponse.bodyToFlux]. * - * Backpressure is controlled by [batchSize] parameter that controls the size of in-flight elements - * and [org.reactivestreams.Subscription.request] size. - * * @author Sebastien Deleuze * @since 5.2 */ -@FlowPreview -inline fun ClientResponse.bodyToFlow(batchSize: Int = 1): Flow = - bodyToFlux().asFlow(batchSize) +@ExperimentalCoroutinesApi +inline fun ClientResponse.bodyToFlow(): Flow = + bodyToFlux().asFlow() /** * Extension for [ClientResponse.toEntity] providing a `toEntity()` variant diff --git a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/WebClientExtensions.kt b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/WebClientExtensions.kt index fed3f65291..cb4ce06345 100644 --- a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/WebClientExtensions.kt +++ b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/WebClientExtensions.kt @@ -16,7 +16,7 @@ package org.springframework.web.reactive.function.client -import kotlinx.coroutines.FlowPreview +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.reactive.awaitSingle import kotlinx.coroutines.reactive.flow.asFlow @@ -75,7 +75,7 @@ inline fun RequestBodySpec.bodyWithType(publisher: Publisher RequestBodySpec.bodyWithType(flow: Flow): RequestHeadersSpec<*> = body(flow, object : ParameterizedTypeReference() {}) @@ -115,15 +115,12 @@ inline fun WebClient.ResponseSpec.bodyToFlux(): Flux = /** * Coroutines [kotlinx.coroutines.flow.Flow] based variant of [WebClient.ResponseSpec.bodyToFlux]. * - * Backpressure is controlled by [batchSize] parameter that controls the size of in-flight elements - * and [org.reactivestreams.Subscription.request] size. - * * @author Sebastien Deleuze * @since 5.2 */ -@FlowPreview +@ExperimentalCoroutinesApi inline fun WebClient.ResponseSpec.bodyToFlow(batchSize: Int = 1): Flow = - bodyToFlux().asFlow(batchSize) + bodyToFlux().asFlow() /** * Coroutines variant of [WebClient.ResponseSpec.bodyToMono]. diff --git a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensions.kt b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensions.kt index b9209816a5..e17a2dd204 100644 --- a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensions.kt +++ b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensions.kt @@ -16,7 +16,7 @@ package org.springframework.web.reactive.function.server -import kotlinx.coroutines.FlowPreview +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.reactive.awaitFirstOrNull import kotlinx.coroutines.reactive.awaitSingle @@ -54,15 +54,12 @@ inline fun ServerRequest.bodyToFlux(): Flux = /** * Coroutines [kotlinx.coroutines.flow.Flow] based variant of [ServerRequest.bodyToFlux]. * - * Backpressure is controlled by [batchSize] parameter that controls the size of in-flight elements - * and [org.reactivestreams.Subscription.request] size. - * * @author Sebastien Deleuze * @since 5.2 */ -@FlowPreview -inline fun ServerRequest.bodyToFlow(batchSize: Int = 1): Flow = - bodyToFlux().asFlow(batchSize) +@ExperimentalCoroutinesApi +inline fun ServerRequest.bodyToFlow(): Flow = + bodyToFlux().asFlow() /** * Non-nullable Coroutines variant of [ServerRequest.bodyToMono]. diff --git a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensions.kt b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensions.kt index 01b8345f1a..9703a699ae 100644 --- a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensions.kt +++ b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensions.kt @@ -16,7 +16,7 @@ package org.springframework.web.reactive.function.server -import kotlinx.coroutines.FlowPreview +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.reactive.awaitSingle import org.reactivestreams.Publisher @@ -85,7 +85,7 @@ suspend fun ServerResponse.BodyBuilder.bodyAndAwait(body: Any): ServerResponse = * @author Sebastien Deleuze * @since 5.2 */ -@FlowPreview +@ExperimentalCoroutinesApi suspend inline fun ServerResponse.BodyBuilder.bodyAndAwait(flow: Flow): ServerResponse = body(flow, object : ParameterizedTypeReference() {}).awaitSingle() diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/ClientResponseExtensionsTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/ClientResponseExtensionsTests.kt index dc5ee9f183..e07d8d22bb 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/ClientResponseExtensionsTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/ClientResponseExtensionsTests.kt @@ -19,7 +19,7 @@ package org.springframework.web.reactive.function.client import io.mockk.every import io.mockk.mockk import io.mockk.verify -import kotlinx.coroutines.FlowPreview +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import org.junit.Assert.assertEquals import org.junit.Assert.assertNull @@ -51,7 +51,7 @@ class ClientResponseExtensionsTests { } @Test - @FlowPreview + @ExperimentalCoroutinesApi fun `bodyToFlow with reified type parameters`() { response.bodyToFlow>() verify { response.bodyToFlux(object : ParameterizedTypeReference>() {}) } diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/WebClientExtensionsTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/WebClientExtensionsTests.kt index 7d3bf3fb74..f0ee54fdef 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/WebClientExtensionsTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/WebClientExtensionsTests.kt @@ -19,7 +19,7 @@ package org.springframework.web.reactive.function.client import io.mockk.every import io.mockk.mockk import io.mockk.verify -import kotlinx.coroutines.FlowPreview +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.runBlocking import org.junit.Assert.assertEquals @@ -34,6 +34,7 @@ import java.util.concurrent.CompletableFuture * * @author Sebastien Deleuze */ +@ExperimentalCoroutinesApi class WebClientExtensionsTests { private val requestBodySpec = mockk(relaxed = true) @@ -49,7 +50,6 @@ class WebClientExtensionsTests { } @Test - @FlowPreview fun `RequestBodySpec#body with Flow and reified type parameters`() { val body = mockk>>() requestBodySpec.bodyWithType(body) @@ -57,7 +57,6 @@ class WebClientExtensionsTests { } @Test - @FlowPreview fun `RequestBodySpec#body with CompletableFuture and reified type parameters`() { val body = mockk>>() requestBodySpec.bodyWithType>(body) @@ -77,7 +76,6 @@ class WebClientExtensionsTests { } @Test - @FlowPreview fun `bodyToFlow with reified type parameters`() { responseSpec.bodyToFlow>() verify { responseSpec.bodyToFlux(object : ParameterizedTypeReference>() {}) } diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensionsTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensionsTests.kt index 537f007ea7..9e8408557c 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensionsTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensionsTests.kt @@ -14,12 +14,12 @@ * limitations under the License. */ -package org.springframework.web.reactive.function.client +package org.springframework.web.reactive.function.server import io.mockk.every import io.mockk.mockk import io.mockk.verify -import kotlinx.coroutines.FlowPreview +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import org.junit.Assert.assertEquals import org.junit.Assert.assertNull @@ -27,7 +27,6 @@ import org.junit.Test import org.springframework.core.ParameterizedTypeReference import org.springframework.http.codec.multipart.Part import org.springframework.util.MultiValueMap -import org.springframework.web.reactive.function.server.* import org.springframework.web.server.WebSession import reactor.core.publisher.Mono import java.security.Principal @@ -54,7 +53,7 @@ class ServerRequestExtensionsTests { } @Test - @FlowPreview + @ExperimentalCoroutinesApi fun `bodyToFlow with reified type parameters`() { request.bodyToFlow>() verify { request.bodyToFlux(object : ParameterizedTypeReference>() {}) } diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensionsTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensionsTests.kt index 00525f3e32..c0486dcdbb 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensionsTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensionsTests.kt @@ -20,7 +20,7 @@ import io.mockk.every import io.mockk.mockk import io.mockk.verify import io.reactivex.Flowable -import kotlinx.coroutines.FlowPreview +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.runBlocking import org.junit.Assert.assertEquals @@ -77,7 +77,7 @@ class ServerResponseExtensionsTests { } @Test - @FlowPreview + @ExperimentalCoroutinesApi fun `BodyBuilder#bodyAndAwait with flow parameter`() { val response = mockk() val body = mockk>>() diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/CoroutinesIntegrationTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/CoroutinesIntegrationTests.kt index f2722552e3..72d3cd2057 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/CoroutinesIntegrationTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/CoroutinesIntegrationTests.kt @@ -17,7 +17,7 @@ package org.springframework.web.reactive.result.method.annotation import kotlinx.coroutines.Deferred -import kotlinx.coroutines.FlowPreview +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.async import kotlinx.coroutines.delay @@ -36,7 +36,7 @@ import org.springframework.web.bind.annotation.RestController import org.springframework.web.client.HttpServerErrorException import org.springframework.web.reactive.config.EnableWebFlux -@FlowPreview +@ExperimentalCoroutinesApi class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() { override fun initApplicationContext(): ApplicationContext {