Merge pull request #4428 from vector-im/feature/fre/fix_optional_npe

Fix potential NPE on Optional objects
This commit is contained in:
Benoit Marty 2021-11-08 16:37:24 +01:00 committed by GitHub
commit 9ebc234e8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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()
}
}