Cause in Kotlin there is no point to write event.e...
# announcements
m
Cause in Kotlin there is no point to write event.eventSource == null test, as at Kotlin level the event.eventSource will always be non-null
k
I've not really used GSON, but what about trying to call
copy()
and seeing if that throws a
NullPointerException
as a workaround?
a
I use Gson on Android and it does throw an exception when you try to set null as a non-null field in the object. The message is basically the object is expected to be non-nullable but was null. So I would say that should be the expected behavior. I would open an issue with Gson at gitlab if it is not what is happening
m
Actually I am not even sure if it is Gson issue or a SpringBoot issue.
@karelpeeters -- a copy() does the trick, but is there a more elegant way of doing so?
k
hashcode()
propably works too. But a real solution would have to be part of the deserializer, this really isn't Kotlins problem.
m
That's true -- but how Kotlin could prevent Java code bypass Kotlin restrictions?
k
Well they're using reflection, and that's exactly what reflection is for: bypassing the normal safety checks.
m
I see. Well, evil...