Nok Ah
08/14/2024, 4:23 PMitems.find. The exception message is: Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.example.models.Item.getId()' on a null object reference. How could this be happening?
class ItemRepositoryImpl : ItemRepository {
private val items = mutableListOf<Item>()
private fun processItem(inputItem: InputItem?, subject: BehaviorSubject<ItemState>) {
if (inputItem != null) {
items.find { it.id == inputItem.itemId }?.let {
it.markAsProcessed()
it.isActive = true
}
subject.onNext(ItemState.ShowItem(inputItem))
} else {
subject.onNext(ItemState.Empty)
}
}
}
How could this be causing an NPE when items.find is called?Michael Krussel
08/14/2024, 5:36 PMitems.If there is more happening, could be issues where another thread is getting access to ItemRepositoryImpl before it is fully constructed. Could be that something is casting items to something that allows inserting a null into it.
Another thought is that intrinsics are complaining that Item.id is null because something like a serializer deserialized a null into it.Dale Hawkins
08/15/2024, 11:35 AMNok Ah
08/17/2024, 6:26 AMBrajesh
09/12/2024, 6:59 AM