jeggy
11/10/2022, 5:39 PMjava.lang.NullPointerException: null cannot be cast to non-null type kotlin.Number
at com.apurebase.puredynamic.repository.user.mapping.UserMapping.<init>(UserMapping.kt:69) ~[main/:?]
at com.apurebase.puredynamic.repository.user.mapping.UserMapping.<init>(UserMapping.kt:10) ~[main/:?]
Joffrey
11/10/2022, 5:40 PM<init>
is indeed referring to the constructor of UserMapping
.
Are there any more lines in the stacktace? Are you running a regular Kotlin program or a Kotlin Script?jeggy
11/10/2022, 5:44 PMclass UserMapping(di: DI, tableSchema: String? = null) : ModelMapping<User>(
name = "USERS",
config = di.direct.instance(),
tableSchema = tableSchema
), ApbVersionedWithTimestamp {
I just restructured my models (about 1000 dataclasses) to use Number
instead of Int
. And now I get this runtime error, but it doesn't point out what or where that is causing it to fail đJoffrey
11/10/2022, 5:45 PMI just restructured my models (about 1000 dataclasses) to use Number instead of IntWow, now I am quite curious as to why đ
jeggy
11/10/2022, 5:47 PMNumber
instead of Long
đ
But seems like I put myself in a bad situation.Joffrey
11/10/2022, 5:47 PMJoffrey
11/10/2022, 5:51 PMAlan B
11/10/2022, 5:52 PMCasey Brooks
11/10/2022, 5:53 PMNumber
, since it doesnât really have a physical meaning (itâs an abstract class and doesnât correspond to any particular primitive type, unlike int, double, etc.). In this case, Iâd suspect the framework to pass null
when it cannot perform the value mapping, which can cause these kinds of strange NPEs that shouldnât be able to happen in pure Kotlin code
Maybe consider converting everything to Double
instead of Number
?jeggy
11/10/2022, 6:19 PM