aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2019-04-16 18:07:11 +0200
committerRobert Jaros <rjaros@finn.pl>2019-04-16 18:07:11 +0200
commit856d753c7f335dacd9cc4daf666a152378886200 (patch)
tree549c667ba6047a0405bd112d8e91be117c798012
parent2382d82d5aaed8e6519da9e82d771ee94007b2cd (diff)
downloadkvision-856d753c7f335dacd9cc4daf666a152378886200.tar.gz
kvision-856d753c7f335dacd9cc4daf666a152378886200.tar.bz2
kvision-856d753c7f335dacd9cc4daf666a152378886200.zip
Upgrade Kotlin to 1.3.30
Upgrade coroutines to 1.2.0 Upgrade serialization to 0.11.0 Upgrade Ktor to 1.1.4 Upgrade Spring Boot to 2.1.4
-rw-r--r--gradle.properties10
-rw-r--r--kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt2
-rw-r--r--kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/Utils.kt14
-rw-r--r--kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt21
-rw-r--r--kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt25
-rw-r--r--kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt22
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/Form.kt10
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/utils/JSON.kt14
8 files changed, 60 insertions, 58 deletions
diff --git a/gradle.properties b/gradle.properties
index a228c62e..7b32ee5c 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,16 +1,16 @@
group=pl.treksoft
version=0.0.33
-kotlinVersion=1.3.21
+kotlinVersion=1.3.30
javaVersion=1.8
-coroutinesVersion=1.1.1
-serializationVersion=0.10.0
+coroutinesVersion=1.2.0
+serializationVersion=0.11.0
frontendPluginVersion=0.0.45
dokkaVersion=0.9.18
detektVersion=1.0.0.RC9.2
junitVersion=4.12
joobyVersion=1.6.0
-springBootVersion=2.1.3.RELEASE
-ktorVersion=1.1.3
+springBootVersion=2.1.4.RELEASE
+ktorVersion=1.1.4
guiceVersion=4.2.2
pac4jVersion=3.5.0
dependencyManagementPluginVersion=1.0.4.RELEASE
diff --git a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt
index 52c0f7c3..06e150e4 100644
--- a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt
+++ b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt
@@ -198,7 +198,7 @@ interface RemoteAgent {
}
}
- private fun findEnumValue(kClass: KClass<Any>, value: String): Any? {
+ fun findEnumValue(kClass: KClass<Any>, value: String): Any? {
return (kClass.asDynamic().jClass.values() as Array<Any>).find {
it.asDynamic().name == value
}
diff --git a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/Utils.kt b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/Utils.kt
index c4f4ed6d..465fbf59 100644
--- a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/Utils.kt
+++ b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/Utils.kt
@@ -22,8 +22,9 @@
package pl.treksoft.kvision.remote
import kotlinx.serialization.SerializationStrategy
-import kotlinx.serialization.context.SimpleModule
import kotlinx.serialization.json.Json
+import kotlinx.serialization.json.JsonConfiguration
+import kotlinx.serialization.modules.serializersModuleOf
import pl.treksoft.kvision.types.JsonDateSerializer
import kotlin.browser.window
import kotlin.js.Date
@@ -45,13 +46,12 @@ fun obj(init: dynamic.() -> Unit): dynamic {
*/
object JSON {
- val plain = Json().apply {
- install(SimpleModule(Date::class, JsonDateSerializer))
- }
+ val plain = Json(context = serializersModuleOf(Date::class, JsonDateSerializer))
- val nonstrict = Json(strictMode = false).apply {
- install(SimpleModule(Date::class, JsonDateSerializer))
- }
+ val nonstrict = Json(
+ configuration = JsonConfiguration.Stable.copy(strictMode = false),
+ context = serializersModuleOf(Date::class, JsonDateSerializer)
+ )
/**
* An extension function to convert Serializable object to JS dynamic object
diff --git a/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt b/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt
index ca08b080..c3c179fc 100644
--- a/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt
+++ b/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt
@@ -30,8 +30,6 @@ import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.channels.SendChannel
-import kotlinx.coroutines.channels.filterNotNull
-import kotlinx.coroutines.channels.map
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import org.jooby.Kooby
@@ -344,16 +342,19 @@ actual open class KVServiceManager<T : Any> actual constructor(val serviceClass:
ws.close()
}
launch {
- val requestChannel = incoming.map {
- val jsonRpcRequest = getParameter<JsonRpcRequest>(it)
- if (jsonRpcRequest.params.size == 1) {
- getParameter<PAR1>(jsonRpcRequest.params[0])
- } else {
- null
- }
- }.filterNotNull()
+ val requestChannel = Channel<PAR1>()
val responseChannel = Channel<PAR2>()
coroutineScope {
+ launch {
+ for (p in incoming) {
+ val jsonRpcRequest = getParameter<JsonRpcRequest>(p)
+ if (jsonRpcRequest.params.size == 1) {
+ val par = getParameter<PAR1>(jsonRpcRequest.params[0])
+ requestChannel.send(par)
+ }
+ }
+ requestChannel.close()
+ }
launch(Dispatchers.IO) {
for (p in responseChannel) {
val text = mapper.writeValueAsString(
diff --git a/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt b/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt
index 11771cfa..3c5391b6 100644
--- a/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt
+++ b/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt
@@ -44,8 +44,6 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.channels.SendChannel
-import kotlinx.coroutines.channels.filterNotNull
-import kotlinx.coroutines.channels.map
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import org.slf4j.Logger
@@ -378,20 +376,23 @@ actual open class KVServiceManager<T : Any> actual constructor(val serviceClass:
webSocketRequests["/kvws/$routeDef"] = {
val wsInjector = call.injector.createChildInjector(WsSessionModule(this))
val service = wsInjector.getInstance(serviceClass.java)
- val requestChannel = incoming.map {
- (it as? Frame.Text)?.readText()?.let { text ->
- val jsonRpcRequest = getParameter<JsonRpcRequest>(text)
- if (jsonRpcRequest.params.size == 1) {
- getParameter<PAR1>(jsonRpcRequest.params[0])
- } else {
- null
- }
- }
- }.filterNotNull()
+ val requestChannel = Channel<PAR1>()
val responseChannel = Channel<PAR2>()
val session = this
coroutineScope {
launch {
+ for (p in incoming) {
+ (p as? Frame.Text)?.readText()?.let { text ->
+ val jsonRpcRequest = getParameter<JsonRpcRequest>(text)
+ if (jsonRpcRequest.params.size == 1) {
+ val par = getParameter<PAR1>(jsonRpcRequest.params[0])
+ requestChannel.send(par)
+ }
+ }
+ }
+ requestChannel.close()
+ }
+ launch {
for (p in responseChannel) {
val text = mapper.writeValueAsString(
JsonRpcResponse(
diff --git a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt
index af185f19..d2b4f7ea 100644
--- a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt
+++ b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt
@@ -23,14 +23,11 @@ package pl.treksoft.kvision.remote
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import kotlinx.coroutines.CoroutineStart
-import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.channels.SendChannel
-import kotlinx.coroutines.channels.filterNotNull
-import kotlinx.coroutines.channels.map
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import org.slf4j.Logger
@@ -420,17 +417,20 @@ actual open class KVServiceManager<T : Any> actual constructor(val serviceClass:
WebSocketSessionHolder.webSocketSession = webSocketSession
ctx.getBean(serviceClass.java)
}
- val requestChannel = incoming.map {
- val jsonRpcRequest = getParameter<JsonRpcRequest>(it)
- if (jsonRpcRequest.params.size == 1) {
- getParameter<PAR1>(jsonRpcRequest.params[0])
- } else {
- null
- }
- }.filterNotNull()
+ val requestChannel = Channel<PAR1>()
val responseChannel = Channel<PAR2>()
coroutineScope {
launch {
+ for (p in incoming) {
+ val jsonRpcRequest = getParameter<JsonRpcRequest>(p)
+ if (jsonRpcRequest.params.size == 1) {
+ val par = getParameter<PAR1>(jsonRpcRequest.params[0])
+ requestChannel.send(par)
+ }
+ }
+ requestChannel.close()
+ }
+ launch {
for (p in responseChannel) {
val text = mapper.writeValueAsString(
JsonRpcResponse(
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/Form.kt b/src/main/kotlin/pl/treksoft/kvision/form/Form.kt
index a2d6848c..2c71e6a1 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/Form.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/Form.kt
@@ -24,8 +24,7 @@ package pl.treksoft.kvision.form
import kotlinx.serialization.ImplicitReflectionSerializer
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Mapper
-import kotlinx.serialization.context.MutableSerialContextImpl
-import kotlinx.serialization.decode
+import kotlinx.serialization.modules.serializersModuleOf
import kotlinx.serialization.serializer
import pl.treksoft.kvision.i18n.I18n.trans
import pl.treksoft.kvision.types.DateSerializer
@@ -107,9 +106,10 @@ class Form<K : Any>(private val panel: FormPanel<K>? = null, private val seriali
else -> listOf(entry.key to entry.value)
}
}.toMap()
- val mapper = Mapper().InNullableMapper(FormMapWrapper(map))
- mapper.context = MutableSerialContextImpl().apply { registerSerializer(Date::class, DateSerializer) }
- mapper.decode(serializer)
+ Mapper(context = serializersModuleOf(Date::class, DateSerializer)).unmapNullable(
+ serializer,
+ FormMapWrapper(map)
+ )
}
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/utils/JSON.kt b/src/main/kotlin/pl/treksoft/kvision/utils/JSON.kt
index e30935ab..8dd8a504 100644
--- a/src/main/kotlin/pl/treksoft/kvision/utils/JSON.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/utils/JSON.kt
@@ -23,8 +23,9 @@ package pl.treksoft.kvision.utils
import kotlinx.serialization.ImplicitReflectionSerializer
import kotlinx.serialization.SerializationStrategy
-import kotlinx.serialization.context.SimpleModule
import kotlinx.serialization.json.Json
+import kotlinx.serialization.json.JsonConfiguration
+import kotlinx.serialization.modules.serializersModuleOf
import kotlinx.serialization.serializer
import pl.treksoft.kvision.types.DateSerializer
import kotlin.js.Date
@@ -34,13 +35,12 @@ import kotlin.js.Date
*/
object JSON {
- val plain = Json().apply {
- install(SimpleModule(Date::class, DateSerializer))
- }
+ val plain = Json(context = serializersModuleOf(Date::class, DateSerializer))
- val nonstrict = Json(strictMode = false).apply {
- install(SimpleModule(Date::class, DateSerializer))
- }
+ val nonstrict = Json(
+ configuration = JsonConfiguration.Stable.copy(strictMode = false),
+ context = serializersModuleOf(Date::class, DateSerializer)
+ )
/**
* An extension function to convert Serializable object to JS dynamic object