Upgrade to Coroutines 1.3.0-M2
This commit is contained in:
parent
47d60b34f8
commit
ca75c2843a
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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 <T: Any> monoToDeferred(source: Mono<T>) =
|
|||
* @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) {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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 <reified T : Any> RSocketRequester.RequestSpec.dataWithType(publisher
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.2
|
||||
*/
|
||||
@FlowPreview
|
||||
@ExperimentalCoroutinesApi
|
||||
inline fun <reified T : Any> RSocketRequester.RequestSpec.dataWithType(flow: Flow<T>): RSocketRequester.ResponseSpec =
|
||||
data(flow, object : ParameterizedTypeReference<T>() {})
|
||||
|
||||
|
|
@ -120,9 +120,9 @@ suspend inline fun <reified T : Any> RSocketRequester.ResponseSpec.retrieveAndAw
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.2
|
||||
*/
|
||||
@FlowPreview
|
||||
inline fun <reified T : Any> RSocketRequester.ResponseSpec.retrieveFlow(batchSize: Int = 1): Flow<T> =
|
||||
retrieveFlux(object : ParameterizedTypeReference<T>() {}).asFlow(batchSize)
|
||||
@ExperimentalCoroutinesApi
|
||||
inline fun <reified T : Any> RSocketRequester.ResponseSpec.retrieveFlow(): Flow<T> =
|
||||
retrieveFlux(object : ParameterizedTypeReference<T>() {}).asFlow()
|
||||
|
||||
/**
|
||||
* Extension for [RSocketRequester.ResponseSpec.retrieveMono] providing a `retrieveMono<Foo>()`
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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 }
|
||||
|
|
|
|||
|
|
@ -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 <reified T : Any> RequestBodySpec.bodyWithType(publisher: Publisher<T
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.2
|
||||
*/
|
||||
@FlowPreview
|
||||
@ExperimentalCoroutinesApi
|
||||
inline fun <reified T : Any> RequestBodySpec.bodyWithType(flow: Flow<T>): RequestHeadersSpec<*> =
|
||||
body(flow, object : ParameterizedTypeReference<T>() {})
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Flow<Foo>>()
|
||||
requestBodySpec.bodyWithType(body)
|
||||
|
|
|
|||
|
|
@ -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 <reified T : Any> ClientResponse.bodyToFlux(): Flux<T> =
|
|||
/**
|
||||
* 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 <reified T : Any> ClientResponse.bodyToFlow(batchSize: Int = 1): Flow<T> =
|
||||
bodyToFlux<T>().asFlow(batchSize)
|
||||
@ExperimentalCoroutinesApi
|
||||
inline fun <reified T : Any> ClientResponse.bodyToFlow(): Flow<T> =
|
||||
bodyToFlux<T>().asFlow()
|
||||
|
||||
/**
|
||||
* Extension for [ClientResponse.toEntity] providing a `toEntity<Foo>()` variant
|
||||
|
|
|
|||
|
|
@ -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 <reified T : Any> RequestBodySpec.bodyWithType(publisher: Publisher<T
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.2
|
||||
*/
|
||||
@FlowPreview
|
||||
@ExperimentalCoroutinesApi
|
||||
inline fun <reified T : Any> RequestBodySpec.bodyWithType(flow: Flow<T>): RequestHeadersSpec<*> =
|
||||
body(flow, object : ParameterizedTypeReference<T>() {})
|
||||
|
||||
|
|
@ -115,15 +115,12 @@ inline fun <reified T : Any> WebClient.ResponseSpec.bodyToFlux(): Flux<T> =
|
|||
/**
|
||||
* 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 <reified T : Any> WebClient.ResponseSpec.bodyToFlow(batchSize: Int = 1): Flow<T> =
|
||||
bodyToFlux<T>().asFlow(batchSize)
|
||||
bodyToFlux<T>().asFlow()
|
||||
|
||||
/**
|
||||
* Coroutines variant of [WebClient.ResponseSpec.bodyToMono].
|
||||
|
|
|
|||
|
|
@ -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 <reified T : Any> ServerRequest.bodyToFlux(): Flux<T> =
|
|||
/**
|
||||
* 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 <reified T : Any> ServerRequest.bodyToFlow(batchSize: Int = 1): Flow<T> =
|
||||
bodyToFlux<T>().asFlow(batchSize)
|
||||
@ExperimentalCoroutinesApi
|
||||
inline fun <reified T : Any> ServerRequest.bodyToFlow(): Flow<T> =
|
||||
bodyToFlux<T>().asFlow()
|
||||
|
||||
/**
|
||||
* Non-nullable Coroutines variant of [ServerRequest.bodyToMono].
|
||||
|
|
|
|||
|
|
@ -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 <reified T : Any> ServerResponse.BodyBuilder.bodyAndAwait(flow: Flow<T>): ServerResponse =
|
||||
body(flow, object : ParameterizedTypeReference<T>() {}).awaitSingle()
|
||||
|
||||
|
|
|
|||
|
|
@ -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<List<Foo>>()
|
||||
verify { response.bodyToFlux(object : ParameterizedTypeReference<List<Foo>>() {}) }
|
||||
|
|
|
|||
|
|
@ -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<WebClient.RequestBodySpec>(relaxed = true)
|
||||
|
|
@ -49,7 +50,6 @@ class WebClientExtensionsTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
@FlowPreview
|
||||
fun `RequestBodySpec#body with Flow and reified type parameters`() {
|
||||
val body = mockk<Flow<List<Foo>>>()
|
||||
requestBodySpec.bodyWithType(body)
|
||||
|
|
@ -57,7 +57,6 @@ class WebClientExtensionsTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
@FlowPreview
|
||||
fun `RequestBodySpec#body with CompletableFuture and reified type parameters`() {
|
||||
val body = mockk<CompletableFuture<List<Foo>>>()
|
||||
requestBodySpec.bodyWithType<List<Foo>>(body)
|
||||
|
|
@ -77,7 +76,6 @@ class WebClientExtensionsTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
@FlowPreview
|
||||
fun `bodyToFlow with reified type parameters`() {
|
||||
responseSpec.bodyToFlow<List<Foo>>()
|
||||
verify { responseSpec.bodyToFlux(object : ParameterizedTypeReference<List<Foo>>() {}) }
|
||||
|
|
|
|||
|
|
@ -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<List<Foo>>()
|
||||
verify { request.bodyToFlux(object : ParameterizedTypeReference<List<Foo>>() {}) }
|
||||
|
|
|
|||
|
|
@ -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<ServerResponse>()
|
||||
val body = mockk<Flow<List<Foo>>>()
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue