Skip to content

Commit 9ebc234

Browse files
authored
Merge pull request #4428 from vector-im/feature/fre/fix_optional_npe
Fix potential NPE on Optional objects
2 parents 2b58c0e + 8140d90 commit 9ebc234

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

changelog.d/4428.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix potential NullPointerException crashes in Room and User account data sources

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/accountdata/RoomAccountDataDataSource.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ internal class RoomAccountDataDataSource @Inject constructor(@SessionDatabase pr
4343

4444
fun getLiveAccountDataEvent(roomId: String, type: String): LiveData<Optional<RoomAccountDataEvent>> {
4545
return Transformations.map(getLiveAccountDataEvents(roomId, setOf(type))) {
46-
it.firstOrNull()?.toOptional()
46+
it.firstOrNull().toOptional()
4747
}
4848
}
4949

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/UserAccountDataDataSource.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ internal class UserAccountDataDataSource @Inject constructor(@SessionDatabase pr
4141

4242
fun getLiveAccountDataEvent(type: String): LiveData<Optional<UserAccountDataEvent>> {
4343
return Transformations.map(getLiveAccountDataEvents(setOf(type))) {
44-
it.firstOrNull()?.toOptional()
44+
it.firstOrNull().toOptional()
4545
}
4646
}
4747

0 commit comments

Comments
 (0)