From 5c456db3cc24f6a1d944040a4ad224224f3b889c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Thu, 30 Jul 2020 10:18:27 +0200 Subject: [PATCH] Upgrade to Kotlin 1.4 RC - The compiler is configured to retain compatibility with Kotlin 1.3. - Explicit API mode is not yet enabled but could be in the future. - Some exceptions thrown by Kotlin have changed to NullPointerException, see https://youtrack.jetbrains.com/issue/KT-22275 for more details. Closes gh-24171 --- build.gradle | 8 +++++--- .../jdbc/core/JdbcOperationsExtensionsTests.kt | 4 ++-- .../SimpAnnotationMethodMessageHandlerKotlinTests.kt | 4 ++-- .../RequestParamMethodArgumentResolverKotlinTests.kt | 7 +++---- spring-webflux/spring-webflux.gradle | 3 +-- spring-webmvc/spring-webmvc.gradle | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/build.gradle b/build.gradle index b230126ebb0..d67d068b480 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id 'io.spring.dependency-management' version '1.0.9.RELEASE' apply false - id 'org.jetbrains.kotlin.jvm' version '1.3.72' apply false + id 'org.jetbrains.kotlin.jvm' version '1.4.0-rc' apply false id 'org.jetbrains.dokka' version '0.10.1' apply false id 'org.asciidoctor.jvm.convert' version '2.4.0' id 'io.spring.nohttp' version '0.0.5.RELEASE' @@ -29,8 +29,8 @@ configure(allprojects) { project -> mavenBom "io.r2dbc:r2dbc-bom:Arabba-SR5" mavenBom "io.rsocket:rsocket-bom:1.1.0-SNAPSHOT" mavenBom "org.eclipse.jetty:jetty-bom:9.4.30.v20200611" - mavenBom "org.jetbrains.kotlin:kotlin-bom:1.3.72" - mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.3.7" + mavenBom "org.jetbrains.kotlin:kotlin-bom:1.4.0-rc" + mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.3.8-1.4.0-rc" mavenBom "org.junit:junit-bom:5.6.2" } dependencies { @@ -311,6 +311,8 @@ configure([rootProject] + javaProjects) { project -> compileKotlin { kotlinOptions { jvmTarget = "1.8" + languageVersion = "1.3" + apiVersion = "1.3" freeCompilerArgs = ["-Xjsr305=strict"] allWarningsAsErrors = true } diff --git a/spring-jdbc/src/test/kotlin/org/springframework/jdbc/core/JdbcOperationsExtensionsTests.kt b/spring-jdbc/src/test/kotlin/org/springframework/jdbc/core/JdbcOperationsExtensionsTests.kt index c134dc23c28..8c1f39fae4b 100644 --- a/spring-jdbc/src/test/kotlin/org/springframework/jdbc/core/JdbcOperationsExtensionsTests.kt +++ b/spring-jdbc/src/test/kotlin/org/springframework/jdbc/core/JdbcOperationsExtensionsTests.kt @@ -53,7 +53,7 @@ class JdbcOperationsExtensionsTests { @Test // gh-22682 fun `queryForObject with nullable RowMapper-like function`() { every { template.queryForObject(sql, any>(), 3) } returns null - assertThat(template.queryForObject(sql, 3) { _, _ -> null as Int? }).isNull() + assertThat(template.queryForObject(sql, 3) { _, _ -> null }).isNull() verify { template.queryForObject(eq(sql), any>(), eq(3)) } } @@ -130,7 +130,7 @@ class JdbcOperationsExtensionsTests { @Test fun `query with RowMapper-like function`() { - val list = listOf(1, 2, 3) + val list = mutableListOf(1, 2, 3) every { template.query(sql, ofType>(), 3) } returns list assertThat(template.query(sql, 3) { rs, _ -> rs.getInt(1) diff --git a/spring-messaging/src/test/kotlin/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandlerKotlinTests.kt b/spring-messaging/src/test/kotlin/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandlerKotlinTests.kt index 9e49d6dc6ae..37f8debac20 100644 --- a/spring-messaging/src/test/kotlin/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandlerKotlinTests.kt +++ b/spring-messaging/src/test/kotlin/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandlerKotlinTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -132,7 +132,7 @@ class SimpAnnotationMethodMessageHandlerKotlinTests { messageHandler.registerHandler(testController) messageHandler.handleMessage(message) assertThat(testController.exception).isNotNull() - assertThat(testController.exception).isInstanceOf(IllegalArgumentException::class.java) + assertThat(testController.exception).isInstanceOf(NullPointerException::class.java) } private fun createMessage(destination: String, headers: Map): Message { diff --git a/spring-web/src/test/kotlin/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverKotlinTests.kt b/spring-web/src/test/kotlin/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverKotlinTests.kt index 61c32fec346..281771bd636 100644 --- a/spring-web/src/test/kotlin/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverKotlinTests.kt +++ b/spring-web/src/test/kotlin/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverKotlinTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -16,7 +16,6 @@ package org.springframework.web.method.annotation -import org.assertj.core.api.Assertions import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatExceptionOfType import org.junit.jupiter.api.BeforeEach @@ -139,7 +138,7 @@ class RequestParamMethodArgumentResolverKotlinTests { @Test fun resolveNonNullableNotRequiredWithoutParameter() { - assertThatExceptionOfType(TypeCastException::class.java).isThrownBy { + assertThatExceptionOfType(NullPointerException::class.java).isThrownBy { resolver.resolveArgument(nonNullableParamNotRequired, null, webRequest, binderFactory) as String } } @@ -221,7 +220,7 @@ class RequestParamMethodArgumentResolverKotlinTests { request.method = HttpMethod.POST.name request.contentType = MediaType.MULTIPART_FORM_DATA_VALUE - assertThatExceptionOfType(TypeCastException::class.java).isThrownBy { + assertThatExceptionOfType(NullPointerException::class.java).isThrownBy { resolver.resolveArgument(nonNullableMultipartParamNotRequired, null, webRequest, binderFactory) as MultipartFile } } diff --git a/spring-webflux/spring-webflux.gradle b/spring-webflux/spring-webflux.gradle index 45c9eac256c..2e13db7ffd9 100644 --- a/spring-webflux/spring-webflux.gradle +++ b/spring-webflux/spring-webflux.gradle @@ -47,8 +47,7 @@ dependencies { testCompile('org.apache.httpcomponents.client5:httpclient5:5.0') testCompile('org.apache.httpcomponents.core5:httpcore5-reactive:5.0') testCompile("com.squareup.okhttp3:mockwebserver") - testCompile("org.jetbrains.kotlin:kotlin-script-runtime") - testRuntime("org.jetbrains.kotlin:kotlin-scripting-jsr223-embeddable") + testRuntime("org.jetbrains.kotlin:kotlin-scripting-jsr223") testRuntime("org.jruby:jruby") testRuntime("org.python:jython-standalone") testRuntime("org.synchronoss.cloud:nio-multipart-parser") diff --git a/spring-webmvc/spring-webmvc.gradle b/spring-webmvc/spring-webmvc.gradle index 8e573cf4b3e..1da60848bd6 100644 --- a/spring-webmvc/spring-webmvc.gradle +++ b/spring-webmvc/spring-webmvc.gradle @@ -60,8 +60,8 @@ dependencies { testCompile("javax.validation:validation-api") testCompile("io.projectreactor:reactor-core") testCompile("io.reactivex.rxjava3:rxjava") - testCompile("org.jetbrains.kotlin:kotlin-script-runtime") - testRuntime("org.jetbrains.kotlin:kotlin-scripting-jsr223-embeddable") + testRuntime("org.jetbrains.kotlin:kotlin-scripting-jsr223") + testRuntime("org.jetbrains.kotlinx:kotlinx-coroutines-core") // Temporary dependency to fix a NoClassDefFoundError error, should not be necessary testRuntime("org.jruby:jruby") testRuntime("org.python:jython-standalone") testRuntime("org.webjars:underscorejs")