Skip to content

Commit f6fea1a

Browse files
authored
feat: upgrade to Kotlin 1.6.10 (#474)
1 parent f295b02 commit f6fea1a

File tree

10 files changed

+41
-39
lines changed

10 files changed

+41
-39
lines changed

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/CachedValue.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ internal data class ExpiringValue<T> (val value: T, val expiresAt: Instant)
2929
@OptIn(ExperimentalTime::class)
3030
internal class CachedValue<T> (
3131
private var value: ExpiringValue<T>? = null,
32-
private val bufferTime: Duration = Duration.seconds(0),
32+
private val bufferTime: Duration = Duration.ZERO,
3333
private val clock: Clock = Clock.System
3434
) {
35-
constructor(value: T, expiresAt: Instant, bufferTime: Duration = Duration.seconds(0), clock: Clock = Clock.System) : this(ExpiringValue(value, expiresAt), bufferTime, clock)
35+
constructor(value: T, expiresAt: Instant, bufferTime: Duration = Duration.ZERO, clock: Clock = Clock.System) : this(ExpiringValue(value, expiresAt), bufferTime, clock)
3636
private val mu = Mutex()
3737

3838
/**

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/imds/ImdsClient.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import aws.smithy.kotlin.runtime.time.Clock
2626
import aws.smithy.kotlin.runtime.util.Platform
2727
import aws.smithy.kotlin.runtime.util.PlatformProvider
2828
import kotlin.time.Duration
29+
import kotlin.time.Duration.Companion.seconds
2930
import kotlin.time.ExperimentalTime
3031

3132
/**
@@ -70,8 +71,8 @@ public class ImdsClient private constructor(builder: Builder) : InstanceMetadata
7071
init {
7172
require(maxRetries > 0) { "maxRetries must be greater than zero" }
7273
val engine = builder.engine ?: CrtHttpEngine {
73-
connectTimeout = Duration.seconds(1)
74-
socketReadTimeout = Duration.seconds(1)
74+
connectTimeout = 1.seconds
75+
socketReadTimeout = 1.seconds
7576
}
7677

7778
httpClient = sdkHttpClient(engine)
@@ -161,7 +162,7 @@ public class ImdsClient private constructor(builder: Builder) : InstanceMetadata
161162
/**
162163
* Override the time-to-live for the session token
163164
*/
164-
public var tokenTtl: Duration = Duration.seconds(DEFAULT_TOKEN_TTL_SECONDS)
165+
public var tokenTtl: Duration = DEFAULT_TOKEN_TTL_SECONDS.seconds
165166

166167
/**
167168
* Configure the [SdkLogMode] used by the client

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/imds/TokenMiddleware.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import aws.smithy.kotlin.runtime.http.request.url
1717
import aws.smithy.kotlin.runtime.http.response.complete
1818
import aws.smithy.kotlin.runtime.time.Clock
1919
import kotlin.time.Duration
20+
import kotlin.time.Duration.Companion.seconds
2021
import kotlin.time.ExperimentalTime
2122

2223
/**
@@ -32,10 +33,10 @@ internal const val X_AWS_EC2_METADATA_TOKEN = "x-aws-ec2-metadata-token"
3233
@OptIn(ExperimentalTime::class)
3334
internal class TokenMiddleware(
3435
private val httpClient: SdkHttpClient,
35-
private val ttl: Duration = Duration.seconds(DEFAULT_TOKEN_TTL_SECONDS),
36+
private val ttl: Duration = DEFAULT_TOKEN_TTL_SECONDS.seconds,
3637
private val clock: Clock = Clock.System
3738
) : ModifyRequestMiddleware {
38-
private var cachedToken = CachedValue<Token>(null, bufferTime = Duration.seconds(TOKEN_REFRESH_BUFFER_SECONDS), clock = clock)
39+
private var cachedToken = CachedValue<Token>(null, bufferTime = TOKEN_REFRESH_BUFFER_SECONDS.seconds, clock = clock)
3940

4041
override fun install(op: SdkHttpOperation<*, *>) {
4142
op.execution.finalize.register(this)
@@ -71,7 +72,7 @@ internal class TokenMiddleware(
7172
HttpStatusCode.OK -> {
7273
val ttl = call.response.headers[X_AWS_EC2_METADATA_TOKEN_TTL_SECONDS]?.toLong() ?: throw EC2MetadataError(200, "No TTL provided in IMDS response")
7374
val token = call.response.body.readAll() ?: throw EC2MetadataError(200, "No token provided in IMDS response")
74-
val expires = clock.now() + Duration.seconds(ttl)
75+
val expires = clock.now() + ttl.seconds
7576
Token(token, expires)
7677
}
7778
else -> {

aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/config/CachedValueTest.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import kotlinx.coroutines.sync.Mutex
1313
import kotlinx.coroutines.sync.withLock
1414
import kotlinx.coroutines.yield
1515
import kotlin.test.*
16-
import kotlin.time.Duration
16+
import kotlin.time.Duration.Companion.seconds
1717
import kotlin.time.ExperimentalTime
1818

1919
@OptIn(ExperimentalTime::class)
@@ -31,62 +31,62 @@ class CachedValueTest {
3131
@Test
3232
fun testExpiration() = runSuspendTest {
3333
val epoch = Instant.fromEpochSeconds(0)
34-
val expiresAt = epoch + Duration.seconds(10)
34+
val expiresAt = epoch + 10.seconds
3535
val clock = ManualClock(epoch)
3636

3737
val value = CachedValue("foo", expiresAt, clock = clock)
3838

3939
assertFalse(value.isExpired())
4040
assertEquals("foo", value.get())
4141

42-
clock.advance(Duration.seconds(10))
42+
clock.advance(10.seconds)
4343
assertTrue(value.isExpired())
4444
assertNull(value.get())
4545
}
4646

4747
@Test
4848
fun testExpirationBuffer() = runSuspendTest {
4949
val epoch = Instant.fromEpochSeconds(0)
50-
val expiresAt = epoch + Duration.seconds(100)
50+
val expiresAt = epoch + 100.seconds
5151
val clock = ManualClock(epoch)
5252

53-
val value = CachedValue("foo", expiresAt, bufferTime = Duration.seconds(30), clock = clock)
53+
val value = CachedValue("foo", expiresAt, bufferTime = 30.seconds, clock = clock)
5454

5555
assertFalse(value.isExpired())
5656
assertEquals("foo", value.get())
5757

58-
clock.advance(Duration.seconds(70))
58+
clock.advance(70.seconds)
5959
assertTrue(value.isExpired())
6060
assertNull(value.get())
6161
}
6262

6363
@Test
6464
fun testGetOrLoad() = runSuspendTest {
6565
val epoch = Instant.fromEpochSeconds(0)
66-
val expiresAt = epoch + Duration.seconds(100)
66+
val expiresAt = epoch + 100.seconds
6767
val clock = ManualClock(epoch)
6868

69-
val value = CachedValue("foo", expiresAt, bufferTime = Duration.seconds(30), clock = clock)
69+
val value = CachedValue("foo", expiresAt, bufferTime = 30.seconds, clock = clock)
7070

7171
var count = 0
7272
val mu = Mutex()
7373
val initializer = suspend {
7474
mu.withLock { count++ }
75-
ExpiringValue("bar", expiresAt + Duration.seconds(count * 100))
75+
ExpiringValue("bar", expiresAt + count.seconds * 100)
7676
}
7777

7878
assertFalse(value.isExpired())
7979
assertEquals("foo", value.getOrLoad(initializer))
8080
assertEquals(0, count)
8181

8282
// t = 90
83-
clock.advance(Duration.seconds(90))
83+
clock.advance(90.seconds)
8484
assertEquals("bar", value.getOrLoad(initializer))
8585
assertFalse(value.isExpired())
8686
assertEquals(1, count)
8787

8888
// t = 180
89-
clock.advance(Duration.seconds(90))
89+
clock.advance(90.seconds)
9090
repeat(10) {
9191
async {
9292
value.getOrLoad(initializer)

aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/config/imds/ImdsClientTest.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import io.kotest.matchers.string.shouldContain
2121
import kotlinx.coroutines.withTimeout
2222
import kotlinx.serialization.json.*
2323
import kotlin.test.*
24-
import kotlin.time.Duration
24+
import kotlin.time.Duration.Companion.seconds
2525
import kotlin.time.ExperimentalTime
2626

2727
@OptIn(ExperimentalTime::class)
@@ -80,12 +80,12 @@ class ImdsClientTest {
8080
engine = connection
8181
endpointConfiguration = EndpointConfiguration.ModeOverride(EndpointMode.IPv6)
8282
clock = testClock
83-
tokenTtl = Duration.seconds(600)
83+
tokenTtl = 600.seconds
8484
}
8585

8686
val r1 = client.get("/latest/metadata")
8787
assertEquals("output 1", r1)
88-
testClock.advance(Duration.seconds(600))
88+
testClock.advance(600.seconds)
8989

9090
val r2 = client.get("/latest/metadata")
9191
assertEquals("output 2", r2)
@@ -127,17 +127,17 @@ class ImdsClientTest {
127127
engine = connection
128128
endpointConfiguration = EndpointConfiguration.ModeOverride(EndpointMode.IPv6)
129129
clock = testClock
130-
tokenTtl = Duration.seconds(600)
130+
tokenTtl = 600.seconds
131131
}
132132

133133
val r1 = client.get("/latest/metadata")
134134
assertEquals("output 1", r1)
135-
testClock.advance(Duration.seconds(400))
135+
testClock.advance(400.seconds)
136136

137137
val r2 = client.get("/latest/metadata")
138138
assertEquals("output 2", r2)
139139

140-
testClock.advance(Duration.seconds(150))
140+
testClock.advance(150.seconds)
141141
val r3 = client.get("/latest/metadata")
142142
assertEquals("output 3", r3)
143143

aws-runtime/aws-signing/jvm/test/aws/sdk/kotlin/runtime/auth/signing/Sigv4TestSuite.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import kotlin.io.path.exists
3232
import kotlin.io.path.name
3333
import kotlin.io.path.readText
3434
import kotlin.test.*
35-
import kotlin.time.Duration
35+
import kotlin.time.Duration.Companion.seconds
3636
import kotlin.time.ExperimentalTime
3737

3838
private const val DEFAULT_SIGNING_ISO_DATE = "2015-08-30T12:36:00Z"
@@ -205,7 +205,7 @@ class Sigv4TestSuite {
205205
config.service = json["service"]!!.jsonPrimitive.content
206206

207207
json["expiration_in_seconds"]?.jsonPrimitive?.int?.let {
208-
config.expiresAfter = Duration.seconds(it)
208+
config.expiresAfter = it.seconds
209209
}
210210

211211
json["normalize"]?.jsonPrimitive?.boolean?.let {

aws-runtime/http-client-engine-crt/jvm/test/aws/sdk/kotlin/runtime/http/engine/crt/AsyncStressTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import kotlinx.coroutines.async
2424
import kotlinx.coroutines.withTimeout
2525
import kotlinx.coroutines.yield
2626
import kotlin.test.Test
27-
import kotlin.time.Duration
27+
import kotlin.time.Duration.Companion.seconds
2828
import kotlin.time.ExperimentalTime
2929

3030
class AsyncStressTest : TestWithLocalServer() {
@@ -90,7 +90,7 @@ class AsyncStressTest : TestWithLocalServer() {
9090
}
9191
}
9292

93-
withTimeout(Duration.seconds(5)) {
93+
withTimeout(5.seconds) {
9494
repeat(1_000) {
9595
async {
9696
try {

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import java.util.Properties
66
import java.net.URL
77

88
plugins {
9-
kotlin("jvm") version "1.5.31" apply false
9+
kotlin("jvm") version "1.6.10" apply false
1010
id("org.jetbrains.dokka")
1111
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
1212
}

examples/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
kotlin("jvm") version "1.5.31"
2+
kotlin("jvm") version "1.6.10"
33
}
44

55
val awsSdkKotlinVersion: String by project

gradle.properties

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@ sdkVersion=0.9.6-SNAPSHOT
1212
smithyVersion=1.13.1
1313
smithyGradleVersion=0.5.3
1414
# smithy-kotlin codegen and runtime are versioned together
15-
smithyKotlinVersion=0.7.4-beta
15+
smithyKotlinVersion=0.7.5-SNAPSHOT
1616

1717
# kotlin
18-
kotlinVersion=1.5.31
19-
dokkaVersion=1.5.31
18+
kotlinVersion=1.6.10
19+
dokkaVersion=1.6.0
2020

2121
# kotlin JVM
2222
kotlinJVMTargetVersion=1.8
2323

2424
# kotlin libraries
25-
coroutinesVersion=1.5.1
26-
atomicFuVersion=0.16.1
27-
kotlinxSerializationVersion=1.3.0
28-
ktorVersion=1.6.3
25+
coroutinesVersion=1.5.2
26+
atomicFuVersion=0.17.0
27+
kotlinxSerializationVersion=1.3.1
28+
ktorVersion=1.6.7
2929

3030
# crt
31-
crtKotlinVersion=0.5.0-alpha
31+
crtKotlinVersion=0.5.1-SNAPSHOT
3232

3333
# testing/utility
3434
junitVersion=5.6.2

0 commit comments

Comments
 (0)