Skip to content

Commit

Permalink
Fix launch exception
Browse files Browse the repository at this point in the history
  • Loading branch information
DRSchlaubi committed Dec 28, 2023
1 parent 3a7d33e commit 478bc36
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {

allprojects {
group = "dev.schlaubi.tonbrett"
version = "1.18.5"
version = "1.18.6"

repositories {
mavenCentral()
Expand Down
6 changes: 4 additions & 2 deletions common/src/jvmMain/kotlin/dev/schlaubi/tonbrett/common/Id.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.json.JsonDecoder
import kotlinx.serialization.json.JsonEncoder
import org.bson.types.ObjectId
import org.litote.kmongo.id.toId
import org.litote.kmongo.toId
Expand All @@ -34,15 +36,15 @@ public object IdSerializer : KSerializer<Id<*>> {
PrimitiveSerialDescriptor("MongoID", PrimitiveKind.STRING)

override fun deserialize(decoder: Decoder): Id<*> {
return if (decoder is BsonFlexibleDecoder) {
return if (decoder !is JsonDecoder && decoder is BsonFlexibleDecoder) {
WrappedId<Any>(decoder.reader.readObjectId().toId())
} else {
WrappedId<Any>(decoder.decodeString().toId())
}
}

override fun serialize(encoder: Encoder, value: Id<*>): Unit =
if (encoder is BsonEncoder) {
if (encoder !is JsonEncoder && encoder is BsonEncoder) {
val objectId = ObjectId(value.toString())
encoder.encodeObjectId(objectId)
} else {
Expand Down

0 comments on commit 478bc36

Please sign in to comment.