diff --git a/build.gradle b/build.gradle index 372be3541f..cf35180fe0 100644 --- a/build.gradle +++ b/build.gradle @@ -34,7 +34,7 @@ configure(allprojects) { project -> mavenBom "io.rsocket:rsocket-bom:1.1.0" mavenBom "org.eclipse.jetty:jetty-bom:9.4.40.v20210413" mavenBom "org.jetbrains.kotlin:kotlin-bom:1.5.0" - mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.4.3" + mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.5.0" mavenBom "org.jetbrains.kotlinx:kotlinx-serialization-bom:1.2.0" mavenBom "org.junit:junit-bom:5.7.2" } @@ -316,7 +316,7 @@ configure([rootProject] + javaProjects) { project -> kotlinOptions { languageVersion = "1.3" apiVersion = "1.3" - freeCompilerArgs = ["-Xjsr305=strict", "-Xsuppress-version-warnings"] + freeCompilerArgs = ["-Xjsr305=strict", "-Xsuppress-version-warnings", "-Xopt-in=kotlin.RequiresOptIn"] allWarningsAsErrors = true } } diff --git a/spring-core/kotlin-coroutines/src/main/kotlin/org/springframework/core/CoroutinesUtils.kt b/spring-core/kotlin-coroutines/src/main/kotlin/org/springframework/core/CoroutinesUtils.kt index e62281d8ed..3d716bb685 100644 --- a/spring-core/kotlin-coroutines/src/main/kotlin/org/springframework/core/CoroutinesUtils.kt +++ b/spring-core/kotlin-coroutines/src/main/kotlin/org/springframework/core/CoroutinesUtils.kt @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,10 +17,7 @@ @file:JvmName("CoroutinesUtils") package org.springframework.core -import kotlinx.coroutines.Deferred -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.async +import kotlinx.coroutines.* import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.reactive.awaitSingleOrNull import kotlinx.coroutines.reactor.asFlux @@ -48,6 +45,8 @@ internal fun deferredToMono(source: Deferred) = * @author Sebastien Deleuze * @since 5.2 */ +@Suppress("DEPRECATION") +@OptIn(DelicateCoroutinesApi::class) internal fun monoToDeferred(source: Mono) = GlobalScope.async(Dispatchers.Unconfined) { source.awaitSingleOrNull() } 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 4cddee4468..319680a630 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -102,6 +102,7 @@ inline fun RSocketRequester.RequestSpec.dataWithType(flow: Flo * @author Sebastien Deleuze * @since 5.2 */ +@Suppress("DEPRECATION") suspend fun RSocketRequester.RetrieveSpec.sendAndAwait() { send().awaitSingleOrNull() } @@ -121,6 +122,7 @@ suspend inline fun RSocketRequester.RetrieveSpec.retrieveAndAw * @author Sebastien Deleuze * @since 5.2.1 */ +@Suppress("DEPRECATION") suspend inline fun RSocketRequester.RetrieveSpec.retrieveAndAwaitOrNull(): T? = retrieveMono(object : ParameterizedTypeReference() {}).awaitSingleOrNull() diff --git a/spring-r2dbc/src/main/kotlin/org/springframework/r2dbc/core/DatabaseClientExtensions.kt b/spring-r2dbc/src/main/kotlin/org/springframework/r2dbc/core/DatabaseClientExtensions.kt index 62383fadad..59179281e6 100644 --- a/spring-r2dbc/src/main/kotlin/org/springframework/r2dbc/core/DatabaseClientExtensions.kt +++ b/spring-r2dbc/src/main/kotlin/org/springframework/r2dbc/core/DatabaseClientExtensions.kt @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import kotlinx.coroutines.reactive.awaitSingleOrNull * * @author Sebastien Deleuze */ +@Suppress("DEPRECATION") suspend fun DatabaseClient.GenericExecuteSpec.await() { then().awaitSingleOrNull() } diff --git a/spring-r2dbc/src/main/kotlin/org/springframework/r2dbc/core/RowsFetchSpecExtensions.kt b/spring-r2dbc/src/main/kotlin/org/springframework/r2dbc/core/RowsFetchSpecExtensions.kt index 8921dd36a3..40d7eed602 100644 --- a/spring-r2dbc/src/main/kotlin/org/springframework/r2dbc/core/RowsFetchSpecExtensions.kt +++ b/spring-r2dbc/src/main/kotlin/org/springframework/r2dbc/core/RowsFetchSpecExtensions.kt @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import org.springframework.dao.EmptyResultDataAccessException * * @author Sebastien Deleuze */ +@Suppress("DEPRECATION") suspend fun RowsFetchSpec.awaitOne(): T { return one().awaitSingleOrNull() ?: throw EmptyResultDataAccessException(1) } @@ -34,6 +35,7 @@ suspend fun RowsFetchSpec.awaitOne(): T { * * @author Sebastien Deleuze */ +@Suppress("DEPRECATION") suspend fun RowsFetchSpec.awaitOneOrNull(): T? = one().awaitSingleOrNull() @@ -42,6 +44,7 @@ suspend fun RowsFetchSpec.awaitOneOrNull(): T? = * * @author Sebastien Deleuze */ +@Suppress("DEPRECATION") suspend fun RowsFetchSpec.awaitSingle(): T { return first().awaitSingleOrNull() ?: throw EmptyResultDataAccessException(1) } @@ -51,6 +54,7 @@ suspend fun RowsFetchSpec.awaitSingle(): T { * * @author Sebastien Deleuze */ +@Suppress("DEPRECATION") suspend fun RowsFetchSpec.awaitSingleOrNull(): T? = first().awaitSingleOrNull() diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java index 18088595ea..783992f52c 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java +++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -878,7 +878,7 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init return ReactiveFlowKt.asFlow(publisher); } - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "deprecation"}) @Nullable private static Object awaitSingleOrNull(Publisher publisher, Object continuation) { return AwaitKt.awaitSingleOrNull(publisher, (Continuation) continuation); 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 9e2984cecb..da021887f6 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -114,6 +114,7 @@ suspend fun ClientResponse.awaitBody(clazz: KClass): T = * @author Sebastien Deleuze * @since 5.2 */ +@Suppress("DEPRECATION") suspend inline fun ClientResponse.awaitBodyOrNull(): T? = bodyToMono().awaitSingleOrNull() @@ -124,6 +125,7 @@ suspend inline fun ClientResponse.awaitBodyOrNull(): T? = * @author Igor Manushin * @since 5.3 */ +@Suppress("DEPRECATION") suspend fun ClientResponse.awaitBodyOrNull(clazz: KClass): T? = bodyToMono(clazz.java).awaitSingleOrNull() 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 0d18bc2596..5b1420182c 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.reactive.asFlow import kotlinx.coroutines.reactive.awaitSingle -import kotlinx.coroutines.reactive.awaitSingle import kotlinx.coroutines.reactive.awaitSingleOrNull import kotlinx.coroutines.reactor.asFlux import kotlinx.coroutines.reactor.mono @@ -150,6 +149,7 @@ suspend inline fun WebClient.ResponseSpec.awaitBody() : T = * @author Valentin Shakhov * @since 5.3.6 */ +@Suppress("DEPRECATION") suspend inline fun WebClient.ResponseSpec.awaitBodyOrNull() : T? = when (T::class) { Unit::class -> awaitBodilessEntity().let { Unit as T? } 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 f1a93816ef..d02fa0bb5d 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -98,6 +98,7 @@ suspend fun ServerRequest.awaitBody(clazz: KClass): T = * @author Sebastien Deleuze * @since 5.2 */ +@Suppress("DEPRECATION") suspend inline fun ServerRequest.awaitBodyOrNull(): T? = bodyToMono().awaitSingleOrNull() @@ -108,6 +109,7 @@ suspend inline fun ServerRequest.awaitBodyOrNull(): T? = * @author Igor Manushin * @since 5.3 */ +@Suppress("DEPRECATION") suspend fun ServerRequest.awaitBodyOrNull(clazz: KClass): T? = bodyToMono(clazz.java).awaitSingleOrNull() @@ -135,6 +137,7 @@ suspend fun ServerRequest.awaitMultipartData(): MultiValueMap = * @author Sebastien Deleuze * @since 5.2 */ +@Suppress("DEPRECATION") suspend fun ServerRequest.awaitPrincipal(): Principal? = principal().awaitSingleOrNull()