Skip to content

Commit 19b4f5b

Browse files
committed
added null checks
1 parent aea722c commit 19b4f5b

File tree

1 file changed

+6
-5
lines changed
  • frameworks/Kotlin/ktor/ktor-r2dbc/src/main/kotlin/org/jetbrains/ktor/benchmarks

1 file changed

+6
-5
lines changed

frameworks/Kotlin/ktor/ktor-r2dbc/src/main/kotlin/org/jetbrains/ktor/benchmarks/Hello.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,14 @@ private fun getWorld(
157157
.execute())
158158
.flatMap { r ->
159159
Mono.from(r.map { row, _ ->
160-
val id = row.get(0, Int::class.java)
161-
val randomNumber = row.get(1, Int::class.java)
162-
if (id != null && randomNumber != null) {
163-
World(id, randomNumber)
164-
} else {
160+
val id = row.get("id", Int::class.java) ?: row.get(0, Int::class.java)
161+
val randomNumber = row.get("randomnumber", Int::class.java) ?: row.get(1, Int::class.java)
162+
163+
if (id == null || randomNumber == null) {
165164
throw IllegalStateException("Database returned null values for required fields")
166165
}
166+
167+
World(id, randomNumber)
167168
})
168169
}
169170
}, Connection::close)

0 commit comments

Comments
 (0)