Skip to content

Commit 556d2f0

Browse files
renovate[bot]nulls
andauthored
Update Kotlin core dependencies (#2844)
- removed deprecated api - fixed actual\expected classes - fixed test for JS - @OptIn(ExperimentalNativeApi::class) - fixed import @jsmodule("@react-sigma/*") --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Nariman Abdullin <[email protected]>
1 parent 5eccb1a commit 556d2f0

File tree

13 files changed

+75
-67
lines changed

13 files changed

+75
-67
lines changed

frontend-common/karma.config.d/custom-config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
test: /\.js$/,
99
use: {loader: 'istanbul-instrumenter-loader'},
1010
// fixme: need to exclude Kotlin dependencies
11-
include: [path.resolve(__dirname, '../save-cloud-save-frontend-common/kotlin/')]
11+
include: [path.resolve(__dirname, '../save-cloud-frontend-common/kotlin/')]
1212
}
1313
)
1414
config.coverageIstanbulReporter = {
@@ -24,12 +24,12 @@ config.set({
2424
}
2525
},
2626
proxies: {
27-
// serving mockServiceWorker.js.js from location relative to base url
27+
// serving mockServiceWorker.js from location relative to base url
2828
// the file should be included into Karma's `files` to be served by server at all
29-
'/mockServiceWorker.js': '/base/mockServiceWorker.js',
29+
'/mockServiceWorker.js': '/base/node_modules/mockServiceWorker.js',
3030
},
3131
})
3232

3333
// http://karma-runner.github.io/6.3/config/files.html
34-
// 'All of the relative patterns will get resolved using the basePath first.', where basePath is set by KGP to `node_modules`
35-
config.files.push('./mockServiceWorker.js')
34+
// 'All of the relative patterns will get resolved using the basePath first.', where basePath is NOT set by KGP to `node_modules` after migration to 1.9
35+
config.files.push('./node_modules/mockServiceWorker.js')

gradle/libs.versions.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[versions]
2-
kotlin = "1.9.10"
2+
kotlin = "1.9.22"
33
jetbrains-annotations = "24.0.1"
44
save-cli = "0.3.10"
55
ktor = "2.3.6"
66
okio = "3.3.0"
7-
serialization = "1.6.0"
8-
kotlinx-datetime = "0.4.1"
9-
kotlinx-coroutines = "1.7.3"
7+
serialization = "1.6.3"
8+
kotlinx-datetime = "0.5.0"
9+
kotlinx-coroutines = "1.8.0"
1010
kotlin-wrappers = "1.0.0-pre.634"
1111
spring-boot = "2.7.17"
1212
spring-cloud = "3.1.9"

save-agent/src/commonMain/kotlin/com/saveourtool/save/agent/SaveAgent.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ class SaveAgent(
5151
/**
5252
* The current [AgentState] of this agent. Initial value corresponds to the period when agent needs to finish its configuration.
5353
*/
54-
val state = GenericAtomicReference(AgentState.BUSY)
54+
val state = createGenericAtomicReference(AgentState.BUSY)
5555

5656
// fixme (limitation of old MM): can't use atomic reference to Instant here, because when using `Clock.System.now()` as an assigned value
5757
// Kotlin throws `kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen kotlinx.datetime.Instant...`
58-
private val executionStartSeconds = AtomicLong(0L)
59-
private val saveProcessJob: GenericAtomicReference<Job?> = GenericAtomicReference(null)
58+
private val executionStartSeconds = createAtomicLong(0L)
59+
private val saveProcessJob: GenericAtomicReference<Job?> = createGenericAtomicReference(null)
6060
private val backgroundContext = newSingleThreadContext("background")
6161
private val saveProcessContext = newSingleThreadContext("save-process")
6262
private val reportFormat = Json {

save-agent/src/commonMain/kotlin/com/saveourtool/save/agent/utils/HttpUtils.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import com.saveourtool.save.agent.AgentState
88
import com.saveourtool.save.agent.SaveAgent
99
import com.saveourtool.save.core.logging.logWarn
1010
import com.saveourtool.save.core.utils.runIf
11-
import com.saveourtool.save.utils.AtomicLong
11+
import com.saveourtool.save.utils.createAtomicLong
1212
import com.saveourtool.save.utils.failureOrNotOk
1313
import com.saveourtool.save.utils.fs
1414
import com.saveourtool.save.utils.notOk
@@ -82,7 +82,7 @@ internal suspend fun HttpClient.download(url: String, file: Path): Result<HttpRe
8282
.execute { httpResponse ->
8383
if (httpResponse.status.isSuccess()) {
8484
val channel: ByteReadChannel = httpResponse.body()
85-
val totalBytes = AtomicLong(0L)
85+
val totalBytes = createAtomicLong(0L)
8686
while (!channel.isClosedForRead) {
8787
val packet = channel.readRemaining(DEFAULT_HTTP_BUFFER_SIZE.toLong())
8888
while (!packet.isEmpty) {

save-cloud-common/src/commonMain/kotlin/com/saveourtool/save/utils/PlatformUtils.kt

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import kotlinx.datetime.Clock
1313
/**
1414
* Atomic values
1515
*/
16-
expect class AtomicLong(value: Long) {
16+
interface AtomicLong {
1717
/**
1818
* @return value
1919
*/
@@ -32,12 +32,9 @@ expect class AtomicLong(value: Long) {
3232
}
3333

3434
/**
35-
* Class that holds value and shares atomic reference to the value
36-
*
37-
* @param valueToStore value to store
35+
* Class that holds value and shares atomic reference to the value
3836
*/
39-
@Suppress("USE_DATA_CLASS")
40-
expect class GenericAtomicReference<T>(valueToStore: T) {
37+
interface GenericAtomicReference<T> {
4138
/**
4239
* @return stored value
4340
*/
@@ -61,8 +58,8 @@ class ExpiringValueWrapper<T : Any>(
6158
private val valueGetter: () -> T,
6259
) {
6360
private val expirationTimeSeconds = expirationTime.toLong(DurationUnit.SECONDS)
64-
private val lastUpdateTimeSeconds = AtomicLong(0)
65-
private val value: GenericAtomicReference<T> = GenericAtomicReference(valueGetter())
61+
private val lastUpdateTimeSeconds = createAtomicLong(0)
62+
private val value: GenericAtomicReference<T> = createGenericAtomicReference(valueGetter())
6663

6764
/**
6865
* @return cached value or refreshes the value and returns it
@@ -77,6 +74,18 @@ class ExpiringValueWrapper<T : Any>(
7774
}
7875
}
7976

77+
/**
78+
* @param value
79+
* @return [AtomicLong] with initial value [value]
80+
*/
81+
expect fun createAtomicLong(value: Long): AtomicLong
82+
83+
/**
84+
* @param valueToStore
85+
* @return create [GenericAtomicReference] with initial value [valueToStore]
86+
*/
87+
expect fun <T> createGenericAtomicReference(valueToStore: T): GenericAtomicReference<T>
88+
8089
/**
8190
* @param envName
8291
* @return env variable name

save-cloud-common/src/jsMain/kotlin/com/saveourtool/save/utils/PlatformUtils.kt

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,18 @@
44

55
package com.saveourtool.save.utils
66

7-
actual class AtomicLong actual constructor(value: Long) {
8-
actual fun get(): Long = throw NotImplementedError(NOT_IMPLEMENTED_ON_JS)
7+
actual fun createAtomicLong(value: Long): AtomicLong = object : AtomicLong {
8+
override fun get(): Long = throw NotImplementedError(NOT_IMPLEMENTED_ON_JS)
99

10-
actual fun set(newValue: Long) {
11-
throw NotImplementedError(NOT_IMPLEMENTED_ON_JS)
12-
}
10+
override fun set(newValue: Long) = throw NotImplementedError(NOT_IMPLEMENTED_ON_JS)
1311

14-
actual fun addAndGet(delta: Long): Long = throw NotImplementedError(NOT_IMPLEMENTED_ON_JS)
12+
override fun addAndGet(delta: Long): Long = throw NotImplementedError(NOT_IMPLEMENTED_ON_JS)
1513
}
1614

17-
@Suppress("USE_DATA_CLASS")
18-
actual class GenericAtomicReference<T> actual constructor(valueToStore: T) {
19-
actual fun get(): T = throw NotImplementedError(NOT_IMPLEMENTED_ON_JS)
20-
actual fun set(newValue: T) {
21-
throw NotImplementedError(NOT_IMPLEMENTED_ON_JS)
22-
}
15+
actual fun <T> createGenericAtomicReference(valueToStore: T): GenericAtomicReference<T> = object : GenericAtomicReference<T> {
16+
override fun get(): T = throw NotImplementedError(NOT_IMPLEMENTED_ON_JS)
17+
18+
override fun set(newValue: T) = throw NotImplementedError(NOT_IMPLEMENTED_ON_JS)
2319
}
2420

2521
actual fun getenv(envName: String): String? = throw NotImplementedError(NOT_IMPLEMENTED_ON_JS)

save-cloud-common/src/jvmMain/kotlin/com/saveourtool/save/utils/PlatformUtils.kt

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* Platform utils
3+
*/
4+
15
@file:Suppress("FILE_NAME_MATCH_CLASS")
26
/**
37
* Platform dependent utility methods
@@ -7,13 +11,19 @@
711

812
package com.saveourtool.save.utils
913

10-
actual typealias AtomicLong = java.util.concurrent.atomic.AtomicLong
14+
actual fun createAtomicLong(value: Long): AtomicLong = object : AtomicLong {
15+
private val holder = java.util.concurrent.atomic.AtomicLong(value)
16+
override fun get(): Long = holder.get()
17+
18+
override fun set(newValue: Long) = holder.set(newValue)
19+
20+
override fun addAndGet(delta: Long): Long = holder.addAndGet(delta)
21+
}
1122

12-
@Suppress("USE_DATA_CLASS")
13-
actual class GenericAtomicReference<T> actual constructor(valueToStore: T) {
23+
actual fun <T> createGenericAtomicReference(valueToStore: T): GenericAtomicReference<T> = object : GenericAtomicReference<T> {
1424
private val holder: java.util.concurrent.atomic.AtomicReference<T> = java.util.concurrent.atomic.AtomicReference(valueToStore)
15-
actual fun get(): T = holder.get()
16-
actual fun set(newValue: T) {
25+
override fun get(): T = holder.get()
26+
override fun set(newValue: T) {
1727
holder.set(newValue)
1828
}
1929
}

save-cloud-common/src/nativeMain/kotlin/com/saveourtool/save/utils/PlatformUtils.kt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,22 @@ package com.saveourtool.save.utils
77
import kotlinx.cinterop.ExperimentalForeignApi
88
import kotlinx.cinterop.toKString
99

10-
actual class AtomicLong actual constructor(value: Long) {
11-
private val kotlinAtomicLong = kotlin.native.concurrent.AtomicLong(value)
10+
actual fun createAtomicLong(value: Long): AtomicLong = object : AtomicLong {
11+
private val kotlinAtomicLong = kotlin.concurrent.AtomicLong(value)
1212

13-
actual fun get(): Long = kotlinAtomicLong.value
13+
override fun get(): Long = kotlinAtomicLong.value
1414

15-
actual fun set(newValue: Long) {
15+
override fun set(newValue: Long) {
1616
kotlinAtomicLong.value = newValue
1717
}
1818

19-
actual fun addAndGet(delta: Long): Long = kotlinAtomicLong.addAndGet(delta)
19+
override fun addAndGet(delta: Long): Long = kotlinAtomicLong.addAndGet(delta)
2020
}
2121

22-
@Suppress("USE_DATA_CLASS")
23-
actual class GenericAtomicReference<T> actual constructor(valueToStore: T) {
22+
actual fun <T> createGenericAtomicReference(valueToStore: T): GenericAtomicReference<T> = object : GenericAtomicReference<T> {
2423
private val holder: kotlin.concurrent.AtomicReference<T> = kotlin.concurrent.AtomicReference(valueToStore)
25-
actual fun get(): T = holder.value
26-
actual fun set(newValue: T) {
24+
override fun get(): T = holder.value
25+
override fun set(newValue: T) {
2726
holder.value = newValue
2827
}
2928
}

save-demo-agent/src/nativeTest/kotlin/com/saveoourtool/save/demo/agent/ServerTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import io.ktor.utils.io.core.*
1010
import kotlinx.coroutines.CoroutineScope
1111
import kotlinx.coroutines.Dispatchers
1212
import kotlinx.coroutines.launch
13+
import kotlin.experimental.ExperimentalNativeApi
1314
import kotlin.test.*
1415

1516
class ServerTest {
@@ -27,6 +28,7 @@ class ServerTest {
2728
server.stop()
2829
}
2930

31+
@OptIn(ExperimentalNativeApi::class)
3032
@Test
3133
fun testServerStartup() {
3234
httpClient().use { client ->

save-frontend/karma.config.d/custom-config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ config.set({
2424
}
2525
},
2626
proxies: {
27-
// serving mockServiceWorker.js.js from location relative to base url
27+
// serving mockServiceWorker.js from location relative to base url
2828
// the file should be included into Karma's `files` to be served by server at all
29-
'/mockServiceWorker.js': '/base/mockServiceWorker.js',
29+
'/mockServiceWorker.js': '/base/node_modules/mockServiceWorker.js',
3030
},
3131
})
3232

3333
// http://karma-runner.github.io/6.3/config/files.html
34-
// 'All of the relative patterns will get resolved using the basePath first.', where basePath is set by KGP to `node_modules`
35-
config.files.push('./mockServiceWorker.js')
34+
// 'All of the relative patterns will get resolved using the basePath first.', where basePath is NOT set by KGP to `node_modules` after migration to 1.9
35+
config.files.push('./node_modules/mockServiceWorker.js')

0 commit comments

Comments
 (0)