Fix potential NPE on Optional objects

This commit is contained in:
Florian Renaud 2021-11-08 15:36:29 +01:00
parent 2b58c0e5ab
commit 8140d90826
3 changed files with 3 additions and 2 deletions

1
changelog.d/4428.bugfix Normal file
View File

@ -0,0 +1 @@
Fix potential NullPointerException crashes in Room and User account data sources

View File

@ -43,7 +43,7 @@ internal class RoomAccountDataDataSource @Inject constructor(@SessionDatabase pr
fun getLiveAccountDataEvent(roomId: String, type: String): LiveData<Optional<RoomAccountDataEvent>> {
return Transformations.map(getLiveAccountDataEvents(roomId, setOf(type))) {
it.firstOrNull()?.toOptional()
it.firstOrNull().toOptional()
}
}

View File

@ -41,7 +41,7 @@ internal class UserAccountDataDataSource @Inject constructor(@SessionDatabase pr
fun getLiveAccountDataEvent(type: String): LiveData<Optional<UserAccountDataEvent>> {
return Transformations.map(getLiveAccountDataEvents(setOf(type))) {
it.firstOrNull()?.toOptional()
it.firstOrNull().toOptional()
}
}