diff --git a/.changes/a81866d1-46dd-440c-8e45-79a839aef240.json b/.changes/a81866d1-46dd-440c-8e45-79a839aef240.json new file mode 100644 index 0000000000..d9c25e7533 --- /dev/null +++ b/.changes/a81866d1-46dd-440c-8e45-79a839aef240.json @@ -0,0 +1,6 @@ +{ + "id": "a81866d1-46dd-440c-8e45-79a839aef240", + "type": "misc", + "description": "⚠️ **IMPORTANT**: Upgrade to Kotlin 2.3.0", + "requiresMinorVersionBump": true +} \ No newline at end of file diff --git a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/core/KotlinDependency.kt b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/core/KotlinDependency.kt index f967a689e3..c7de001ab6 100644 --- a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/core/KotlinDependency.kt +++ b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/core/KotlinDependency.kt @@ -37,7 +37,7 @@ private fun getDefaultRuntimeVersion(): String { // publishing info const val RUNTIME_GROUP: String = "aws.smithy.kotlin" val RUNTIME_VERSION: String = System.getProperty("smithy.kotlin.codegen.clientRuntimeVersion", getDefaultRuntimeVersion()) -val KOTLIN_COMPILER_VERSION: String = System.getProperty("smithy.kotlin.codegen.kotlinCompilerVersion", "2.2.0") +val KOTLIN_COMPILER_VERSION: String = System.getProperty("smithy.kotlin.codegen.kotlinCompilerVersion", "2.3.0") enum class SourceSet { CommonMain, diff --git a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/lang/DocumentationPreprocessor.kt b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/lang/DocumentationPreprocessor.kt index 04518e7032..7ab7cb68ca 100644 --- a/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/lang/DocumentationPreprocessor.kt +++ b/codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/lang/DocumentationPreprocessor.kt @@ -207,8 +207,10 @@ private fun Node.filterDescendants(vararg matchers: (Node) -> Boolean) { childNodes().forEach { it.filterDescendants(*matchers) } } -private fun Node.hasAncestor(predicate: (Node) -> Boolean): Boolean = - parent()?.let { predicate(it) || it.hasAncestor(predicate) } == true +private fun Node.hasAncestor(predicate: (Node) -> Boolean): Boolean { + val parent = parent() + return parent != null && (predicate(parent) || parent.hasAncestor(predicate)) +} private fun Node.isList() = nodeName().let { it == "ul" || it == "ol" } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5d04b34af1..c572ab99f6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,60 +1,57 @@ [versions] -kotlin-version = "2.2.0" +kotlin-version = "2.3.0" dokka-version = "2.0.0" +# TODO Upgrade to 0.5.0 before merging aws-kotlin-repo-tools-version = "0.4.64" # libs coroutines-version = "1.10.2" atomicfu-version = "0.29.0" -okhttp-version = "5.1.0" +okhttp-version = "5.3.2" okhttp4-version = "4.12.0" -okio-version = "3.16.0" -otel-version = "1.52.0" +okio-version = "3.16.4" +otel-version = "1.57.0" slf4j-version = "2.0.17" slf4j-v1x-version = "1.7.36" +# TODO Upgrade to 0.12.0 before merging crt-kotlin-version = "0.11.7" -micrometer-version = "1.15.2" +micrometer-version = "1.16.1" binary-compatibility-validator-version = "0.18.1" kotlin-multiplatform-bignum-version = "0.3.10" -kotlinx-datetime-version = "0.6.1" +kotlinx-datetime-version = "0.7.1" publish-plugin-version = "2.0.0" smithy-gradle-plugin-version = "1.3.0" # codegen -smithy-version = "1.64.0" +smithy-version = "1.65.0" # testing -junit-version = "5.13.4" +junit-version = "5.14.1" kotest-version = "5.9.1" -kotlin-compile-testing-version = "0.8.0" -kotlinx-benchmark-version = "0.4.14" +kotlin-compile-testing-version = "0.12.0" +kotlinx-benchmark-version = "0.4.15" kotlinx-serialization-version = "1.9.0" -docker-java-version = "3.5.3" -ktor-version = "3.2.3" +docker-java-version = "3.7.0" +ktor-version = "3.3.3" kaml-version = "0.55.0" -jsoup-version = "1.21.1" +jsoup-version = "1.21.2" [libraries] aws-kotlin-repo-tools-build-support = { module="aws.sdk.kotlin.gradle:build-support", version.ref = "aws-kotlin-repo-tools-version" } kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin-version" } -kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin-version"} -kotlin-stdlib-jdk8 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin-version"} kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin-version" } kotlin-test-junit5 = { module = "org.jetbrains.kotlin:kotlin-test-junit5", version.ref = "kotlin-version" } dokka-core = { module = "org.jetbrains.dokka:dokka-core", version.ref = "dokka-version" } dokka-base = { module = "org.jetbrains.dokka:dokka-base", version.ref = "dokka-version" } dokka-gradle-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka-version" } -kotlinx-atomicfu = { module = "org.jetbrains.kotlinx:atomicfu", version.ref = "atomicfu-version" } kotlinx-atomicfu-plugin = { module = "org.jetbrains.kotlinx:atomicfu-gradle-plugin", version.ref = "atomicfu-version" } kotlinx-coroutines-debug = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-debug", version.ref = "coroutines-version" } kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines-version" } kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines-version" } -kotlinx-coroutines-jdk8 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-jdk8", version.ref = "coroutines-version" } -kotlinx-coroutines-slf4j = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-slf4j", version.ref = "coroutines-version" } okio = { module = "com.squareup.okio:okio", version.ref = "okio-version" } okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp-version" } @@ -64,7 +61,6 @@ opentelemetry-api = { module = "io.opentelemetry:opentelemetry-api", version.ref opentelemetry-sdk-testing = {module = "io.opentelemetry:opentelemetry-sdk-testing", version.ref = "otel-version" } opentelemetry-kotlin-extension = { module = "io.opentelemetry:opentelemetry-extension-kotlin", version.ref = "otel-version" } slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j-version" } -slf4j-api-v1x = { module = "org.slf4j:slf4j-api", version.ref = "slf4j-v1x-version" } slf4j-simple = { module = "org.slf4j:slf4j-simple", version.ref = "slf4j-version" } crt-kotlin = { module = "aws.sdk.kotlin.crt:aws-crt-kotlin", version.ref = "crt-kotlin-version" } micrometer-core = { module = "io.micrometer:micrometer-core", version.ref = "micrometer-version" } @@ -114,7 +110,6 @@ kotlin-multiplatform-bignum = { module = "com.ionspin.kotlin:bignum", version.re smithy-gradle-base-plugin = { module = "software.amazon.smithy.gradle:smithy-base", version.ref = "smithy-gradle-plugin-version" } [plugins] -dokka = { id = "org.jetbrains.dokka", version.ref = "dokka-version"} kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin-version" } kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin-version" } kotlinx-benchmark = { id = "org.jetbrains.kotlinx.benchmark", version.ref = "kotlinx-benchmark-version" } diff --git a/runtime/observability/telemetry-provider-micrometer/jvm/src/aws/smithy/kotlin/runtime/telemetry/micrometer/MicrometerMeterProvider.kt b/runtime/observability/telemetry-provider-micrometer/jvm/src/aws/smithy/kotlin/runtime/telemetry/micrometer/MicrometerMeterProvider.kt index 002da4cdd8..b3b4923f35 100644 --- a/runtime/observability/telemetry-provider-micrometer/jvm/src/aws/smithy/kotlin/runtime/telemetry/micrometer/MicrometerMeterProvider.kt +++ b/runtime/observability/telemetry-provider-micrometer/jvm/src/aws/smithy/kotlin/runtime/telemetry/micrometer/MicrometerMeterProvider.kt @@ -221,7 +221,9 @@ private fun MeterMetadata.counter() = MicrometerCounter.builder(meterName) .tags(extraTags) @Suppress("UNCHECKED_CAST") -private fun Attributes.toTags() = keys.mapNotNull { - val attributeKey = it as? AttributeKey ?: return@mapNotNull null - Tag.of(attributeKey.name, getOrNull(attributeKey).toString()) -}.let(Tags::of) +private fun Attributes.toTags() = Tags.of( + keys.mapNotNull { + val attributeKey = it as? AttributeKey ?: return@mapNotNull null + Tag.of(attributeKey.name, getOrNull(attributeKey).toString()) + }, +) diff --git a/runtime/protocol/aws-event-stream/common/src/aws/smithy/kotlin/runtime/awsprotocol/eventstream/HeaderValue.kt b/runtime/protocol/aws-event-stream/common/src/aws/smithy/kotlin/runtime/awsprotocol/eventstream/HeaderValue.kt index 60df999600..f5558d110b 100644 --- a/runtime/protocol/aws-event-stream/common/src/aws/smithy/kotlin/runtime/awsprotocol/eventstream/HeaderValue.kt +++ b/runtime/protocol/aws-event-stream/common/src/aws/smithy/kotlin/runtime/awsprotocol/eventstream/HeaderValue.kt @@ -145,7 +145,6 @@ public sealed class HeaderValue { when (type) { HeaderType.STRING -> HeaderValue.String(bytes.decodeToString()) HeaderType.BYTE_ARRAY -> HeaderValue.ByteArray(bytes) - else -> throw IllegalStateException("Invalid HeaderValue") } } HeaderType.TIMESTAMP -> { diff --git a/runtime/protocol/http-client-engines/http-client-engine-okhttp/jvm/src/aws/smithy/kotlin/runtime/http/engine/okhttp/HttpEngineEventListener.kt b/runtime/protocol/http-client-engines/http-client-engine-okhttp/jvm/src/aws/smithy/kotlin/runtime/http/engine/okhttp/HttpEngineEventListener.kt index 492650f74d..10bd035efe 100644 --- a/runtime/protocol/http-client-engines/http-client-engine-okhttp/jvm/src/aws/smithy/kotlin/runtime/http/engine/okhttp/HttpEngineEventListener.kt +++ b/runtime/protocol/http-client-engines/http-client-engine-okhttp/jvm/src/aws/smithy/kotlin/runtime/http/engine/okhttp/HttpEngineEventListener.kt @@ -169,7 +169,7 @@ public class HttpEngineEventListener( } override fun responseHeadersEnd(call: Call, response: Response) { - val contentLength = response.body?.contentLength() + val contentLength = response.body.contentLength() trace { "response headers end: contentLengthHeader=$contentLength" } } diff --git a/runtime/protocol/http-client-engines/http-client-engine-okhttp/jvm/src/aws/smithy/kotlin/runtime/http/engine/okhttp/OkHttpEngine.kt b/runtime/protocol/http-client-engines/http-client-engine-okhttp/jvm/src/aws/smithy/kotlin/runtime/http/engine/okhttp/OkHttpEngine.kt index 2958c02135..1f51f6507b 100644 --- a/runtime/protocol/http-client-engines/http-client-engine-okhttp/jvm/src/aws/smithy/kotlin/runtime/http/engine/okhttp/OkHttpEngine.kt +++ b/runtime/protocol/http-client-engines/http-client-engine-okhttp/jvm/src/aws/smithy/kotlin/runtime/http/engine/okhttp/OkHttpEngine.kt @@ -87,7 +87,7 @@ public class OkHttpEngine private constructor( // else). In both cases we need to ensure that the engine-side resources are cleaned up completely // since they wouldn't otherwise be. https://github.com/smithy-lang/smithy-kotlin/issues/1061 if (cause != null) call.cancelInFlight() - engineResponse.body?.close() + engineResponse.body.close() } } } diff --git a/runtime/protocol/http-client-engines/http-client-engine-okhttp/jvm/src/aws/smithy/kotlin/runtime/http/engine/okhttp/OkHttpUtils.kt b/runtime/protocol/http-client-engines/http-client-engine-okhttp/jvm/src/aws/smithy/kotlin/runtime/http/engine/okhttp/OkHttpUtils.kt index 181ed400c3..2cf22394cd 100644 --- a/runtime/protocol/http-client-engines/http-client-engine-okhttp/jvm/src/aws/smithy/kotlin/runtime/http/engine/okhttp/OkHttpUtils.kt +++ b/runtime/protocol/http-client-engines/http-client-engine-okhttp/jvm/src/aws/smithy/kotlin/runtime/http/engine/okhttp/OkHttpUtils.kt @@ -64,7 +64,6 @@ public fun HttpRequest.toOkHttpRequest( when (body) { is HttpBody.SourceContent -> body.readFrom().toHttpBody(it.toLong()) is HttpBody.ChannelContent -> body.readFrom().toHttpBody(it.toLong()) - else -> null } } else { null @@ -111,8 +110,8 @@ public fun OkHttpResponse.toSdkResponse(): HttpResponse { override val isOneShot: Boolean = true // -1 is used by okhttp as transfer-encoding chunked - override val contentLength: Long? = if (body!!.contentLength() >= 0L) body!!.contentLength() else null - override fun readFrom(): SdkSource = body!!.source().toSdk() + override val contentLength: Long? = if (body.contentLength() >= 0L) body.contentLength() else null + override fun readFrom(): SdkSource = body.source().toSdk() } } diff --git a/runtime/protocol/http-client-engines/http-client-engine-okhttp/jvm/test/aws/smithy/kotlin/runtime/http/engine/okhttp/EventListenerChainTest.kt b/runtime/protocol/http-client-engines/http-client-engine-okhttp/jvm/test/aws/smithy/kotlin/runtime/http/engine/okhttp/EventListenerChainTest.kt index c9acb07cef..181342b2ec 100644 --- a/runtime/protocol/http-client-engines/http-client-engine-okhttp/jvm/test/aws/smithy/kotlin/runtime/http/engine/okhttp/EventListenerChainTest.kt +++ b/runtime/protocol/http-client-engines/http-client-engine-okhttp/jvm/test/aws/smithy/kotlin/runtime/http/engine/okhttp/EventListenerChainTest.kt @@ -11,6 +11,7 @@ import java.io.IOException import java.net.InetAddress import java.net.InetSocketAddress import java.net.Proxy +import kotlin.reflect.KClass import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertTrue @@ -272,6 +273,10 @@ class EventListenerChainTest { override fun isExecuted(): Boolean = false override fun request(): Request = Request.Builder().url("https://example.com").build() override fun timeout(): okio.Timeout = okio.Timeout() + override fun tag(type: KClass): T = error("Not used by mock call") + override fun tag(type: Class): T = error("Not used by mock call") + override fun tag(type: KClass, computeIfAbsent: () -> T): T = error("Not used by mock call") + override fun tag(type: Class, computeIfAbsent: () -> T): T = error("Not used by mock call") } private fun createHttpUrl(): HttpUrl = HttpUrl.Builder() diff --git a/runtime/runtime-core/common/src/aws/smithy/kotlin/runtime/smoketests/SmokeTestsFunctions.kt b/runtime/runtime-core/common/src/aws/smithy/kotlin/runtime/smoketests/SmokeTestsFunctions.kt index 8044dc620c..df21b5dbda 100644 --- a/runtime/runtime-core/common/src/aws/smithy/kotlin/runtime/smoketests/SmokeTestsFunctions.kt +++ b/runtime/runtime-core/common/src/aws/smithy/kotlin/runtime/smoketests/SmokeTestsFunctions.kt @@ -13,7 +13,7 @@ public class SmokeTestsException(message: String) : Exception(message) * An [Appendable] which can be used for printing test results to the console */ public val DefaultPrinter: Appendable = object : Appendable { - override fun append(c: Char) = this.also { print(c) } - override fun append(csq: CharSequence?) = this.also { print(csq) } - override fun append(csq: CharSequence?, start: Int, end: Int) = this.also { print(csq?.subSequence(start, end)) } + override fun append(value: Char) = this.also { print(value) } + override fun append(value: CharSequence?) = this.also { print(value) } + override fun append(value: CharSequence?, startIndex: Int, endIndex: Int) = this.also { print(value?.subSequence(startIndex, endIndex)) } } diff --git a/runtime/runtime-core/common/test/aws/smithy/kotlin/runtime/text/Utf8Test.kt b/runtime/runtime-core/common/test/aws/smithy/kotlin/runtime/text/Utf8Test.kt index f45106f288..a4fe900a38 100644 --- a/runtime/runtime-core/common/test/aws/smithy/kotlin/runtime/text/Utf8Test.kt +++ b/runtime/runtime-core/common/test/aws/smithy/kotlin/runtime/text/Utf8Test.kt @@ -21,7 +21,7 @@ class Utf8Test { fun testIsSupplementaryCodePoint() { assertFalse(Char.isSupplementaryCodePoint(-1)) for (c in 0..0xFFFF) { - assertFalse(Char.isSupplementaryCodePoint(c.toInt())) + assertFalse(Char.isSupplementaryCodePoint(c)) } for (c in 0xFFFF + 1..0x10FFFF) { assertTrue(Char.isSupplementaryCodePoint(c)) diff --git a/runtime/runtime-core/jvm/src/aws/smithy/kotlin/runtime/time/InstantJVM.kt b/runtime/runtime-core/jvm/src/aws/smithy/kotlin/runtime/time/InstantJVM.kt index 3f0f1459fa..07db9ba040 100644 --- a/runtime/runtime-core/jvm/src/aws/smithy/kotlin/runtime/time/InstantJVM.kt +++ b/runtime/runtime-core/jvm/src/aws/smithy/kotlin/runtime/time/InstantJVM.kt @@ -25,7 +25,7 @@ import kotlin.time.Duration import kotlin.time.toKotlinDuration import java.time.Duration as jtDuration import java.time.Instant as jtInstant -import kotlinx.datetime.Instant as KtInstant +import kotlin.time.Instant as KtInstant // FIXME Consider making this multiplatform (`common`) using kotlinx.datetime public actual class Instant(internal val value: jtInstant) : Comparable { diff --git a/runtime/runtime-core/native/src/aws/smithy/kotlin/runtime/time/DateTimeFormats.kt b/runtime/runtime-core/native/src/aws/smithy/kotlin/runtime/time/DateTimeFormats.kt index 550a95cfe1..91db60806e 100644 --- a/runtime/runtime-core/native/src/aws/smithy/kotlin/runtime/time/DateTimeFormats.kt +++ b/runtime/runtime-core/native/src/aws/smithy/kotlin/runtime/time/DateTimeFormats.kt @@ -17,7 +17,7 @@ import kotlinx.datetime.format.char import kotlinx.datetime.format.optional /** - * [DateTimeFormat] for use with [kotlinx.datetime.Instant] + * [DateTimeFormat] for use with [kotlin.time.Instant] */ internal object DateTimeFormats { @@ -32,7 +32,7 @@ internal object DateTimeFormats { LocalDate.Format { year() monthNumber() - dayOfMonth() + day() }, ) }) { @@ -42,7 +42,7 @@ internal object DateTimeFormats { char('-') monthNumber() char('-') - dayOfMonth() + day() }, ) } @@ -82,7 +82,7 @@ internal object DateTimeFormats { val ISO_8601_CONDENSED = DateTimeComponents.Format { year() monthNumber() - dayOfMonth() + day() char('T') hour() @@ -97,7 +97,7 @@ internal object DateTimeFormats { val ISO_8601_CONDENSED_DATE = DateTimeComponents.Format { year() monthNumber() - dayOfMonth() + day() } /** @@ -109,9 +109,9 @@ internal object DateTimeFormats { chars(", ") alternativeParsing({ - dayOfMonth(padding = Padding.NONE) + day(padding = Padding.NONE) }) { - dayOfMonth() + day() } char(' ') @@ -141,5 +141,5 @@ internal object DateTimeFormats { internal val ISO_8601_CONDENSED_DATE_LOCALDATE = LocalDate.Format { year() monthNumber() - dayOfMonth() + day() } diff --git a/runtime/runtime-core/native/src/aws/smithy/kotlin/runtime/time/InstantNative.kt b/runtime/runtime-core/native/src/aws/smithy/kotlin/runtime/time/InstantNative.kt index 01edcaf1af..51909e77e7 100644 --- a/runtime/runtime-core/native/src/aws/smithy/kotlin/runtime/time/InstantNative.kt +++ b/runtime/runtime-core/native/src/aws/smithy/kotlin/runtime/time/InstantNative.kt @@ -5,13 +5,14 @@ package aws.smithy.kotlin.runtime.time -import kotlinx.datetime.Clock import kotlinx.datetime.LocalDate import kotlinx.datetime.TimeZone import kotlinx.datetime.atStartOfDayIn import kotlinx.datetime.format +import kotlinx.datetime.parse +import kotlin.time.Clock import kotlin.time.Duration -import kotlinx.datetime.Instant as KtInstant +import kotlin.time.Instant as KtInstant private fun TimestampFormat.asDateTimeFormat() = when (this) { TimestampFormat.RFC_5322 -> DateTimeFormats.RFC_5322 diff --git a/runtime/serde/serde-xml/common/src/aws/smithy/kotlin/runtime/serde/xml/XmlTagReader.kt b/runtime/serde/serde-xml/common/src/aws/smithy/kotlin/runtime/serde/xml/XmlTagReader.kt index 338e2944f4..57a108e189 100644 --- a/runtime/serde/serde-xml/common/src/aws/smithy/kotlin/runtime/serde/xml/XmlTagReader.kt +++ b/runtime/serde/serde-xml/common/src/aws/smithy/kotlin/runtime/serde/xml/XmlTagReader.kt @@ -73,7 +73,7 @@ public class XmlTagReader( cand = nextToken() } - val nextTok = cand as? XmlToken.BeginElement + val nextTok = cand return nextTok?.tagReader(reader).also { newScope -> lastEmitted = newScope