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
This commit is contained in:
Sébastien Deleuze 2020-07-30 10:18:27 +02:00
parent 83e3c332a5
commit 5c456db3cc
6 changed files with 15 additions and 15 deletions

View File

@ -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
}

View File

@ -53,7 +53,7 @@ class JdbcOperationsExtensionsTests {
@Test // gh-22682
fun `queryForObject with nullable RowMapper-like function`() {
every { template.queryForObject(sql, any<RowMapper<Int>>(), 3) } returns null
assertThat(template.queryForObject(sql, 3) { _, _ -> null as Int? }).isNull()
assertThat(template.queryForObject<Int?>(sql, 3) { _, _ -> null }).isNull()
verify { template.queryForObject(eq(sql), any<RowMapper<Int?>>(), 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<RowMapper<*>>(), 3) } returns list
assertThat(template.query(sql, 3) { rs, _ ->
rs.getInt(1)

View File

@ -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<String, String?>): Message<ByteArray> {

View File

@ -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
}
}

View File

@ -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")

View File

@ -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")