From ab1565b79e7234cde2fab98764f41953dadd716b Mon Sep 17 00:00:00 2001 From: vendelieu Date: Sat, 14 Dec 2024 05:01:16 +0300 Subject: [PATCH] fix double parsing --- .../kotlin/eu/vendeli/rethis/commands/GeospatialCommands.kt | 2 +- .../kotlin/eu/vendeli/rethis/utils/ResponseUtils.kt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/commonMain/kotlin/eu/vendeli/rethis/commands/GeospatialCommands.kt b/src/commonMain/kotlin/eu/vendeli/rethis/commands/GeospatialCommands.kt index 68d87415..3270b807 100644 --- a/src/commonMain/kotlin/eu/vendeli/rethis/commands/GeospatialCommands.kt +++ b/src/commonMain/kotlin/eu/vendeli/rethis/commands/GeospatialCommands.kt @@ -55,7 +55,7 @@ suspend fun ReThis.geoPos(key: String, vararg members: String): List().map { entry -> entry.safeCast()?.value?.chunked(2) { - GeoPosition(it.first().unwrap()!!, it.last().unwrap()!!) + GeoPosition(it.first().unwrap()!!, it.last().unwrap()!!) } } diff --git a/src/commonMain/kotlin/eu/vendeli/rethis/utils/ResponseUtils.kt b/src/commonMain/kotlin/eu/vendeli/rethis/utils/ResponseUtils.kt index 659ba73e..7482e4c3 100644 --- a/src/commonMain/kotlin/eu/vendeli/rethis/utils/ResponseUtils.kt +++ b/src/commonMain/kotlin/eu/vendeli/rethis/utils/ResponseUtils.kt @@ -13,7 +13,7 @@ import io.ktor.utils.io.charsets.* import io.ktor.utils.io.core.* import kotlinx.io.Buffer import kotlinx.io.readDecimalLong -import kotlinx.io.readDouble +import kotlinx.io.readString internal suspend fun ByteReadChannel.readRedisMessage(charset: Charset, rawOnly: Boolean = false): RType { val type = RespCode.fromCode(readByte()) // Read the type byte (e.g., +, -, :, $, *) @@ -52,7 +52,7 @@ internal suspend fun ByteReadChannel.readRedisMessage(charset: Charset, rawOnly: else -> exception { "Invalid boolean format: $line" } } - RespCode.DOUBLE -> F64(line.readDouble()) + RespCode.DOUBLE -> F64(line.readString().toDouble()) RespCode.BIG_NUMBER -> try { BigNumber(BigInteger.parseString(line.readText(charset))) @@ -134,7 +134,7 @@ internal suspend fun ByteReadChannel.processRedisSimpleResponse( else -> exception { "Invalid boolean format: $line" } } - RespCode.DOUBLE -> line.readDouble() + RespCode.DOUBLE -> line.readString().toDouble() RespCode.BIG_NUMBER -> try { BigInteger.parseString(line.readText(charset))