Fixed
Status Update
Comments
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit d1cfc7d2f73f5ea75da8ab2ab0d5f195f7eaf829
Author: Simon Schiller <simonschiller@users.noreply.github.com>
Date: Mon Aug 24 00:39:52 2020
[GH] Replace ConcurrentHashMap with Collections.synchronizedMap()
## Proposed Changes
- Replace the `ConcurrentHashMap` inside `RoomDatabase` with `Collections.synchronizedMap()` to avoid issues on Android Lollipop
## Testing
Test: N/A, only switched out a class
## Issues Fixed
Fixes: 162431855
This is an imported pull request fromhttps://github.com/androidx/androidx/pull/71 .
Resolves #71
Github-Pr-Head-Sha: f9c85bc97cd1e0a3cb47e4ae1d7a391b0e843d75
GitOrigin-RevId: 3740d38691ca194a71f02ecd5e0f80bdb36dcae9
Change-Id: Icf3956a89bc0df47dfe53924e8c8f5fc3fde02cc
M room/runtime/src/main/java/androidx/room/RoomDatabase.java
https://android-review.googlesource.com/1407968
Branch: androidx-master-dev
commit d1cfc7d2f73f5ea75da8ab2ab0d5f195f7eaf829
Author: Simon Schiller <simonschiller@users.noreply.github.com>
Date: Mon Aug 24 00:39:52 2020
[GH] Replace ConcurrentHashMap with Collections.synchronizedMap()
## Proposed Changes
- Replace the `ConcurrentHashMap` inside `RoomDatabase` with `Collections.synchronizedMap()` to avoid issues on Android Lollipop
## Testing
Test: N/A, only switched out a class
## Issues Fixed
Fixes: 162431855
This is an imported pull request from
Resolves #71
Github-Pr-Head-Sha: f9c85bc97cd1e0a3cb47e4ae1d7a391b0e843d75
GitOrigin-RevId: 3740d38691ca194a71f02ecd5e0f80bdb36dcae9
Change-Id: Icf3956a89bc0df47dfe53924e8c8f5fc3fde02cc
M room/runtime/src/main/java/androidx/room/RoomDatabase.java
Description
(manually copied from internal b/162303675 )
It seems room/runtime/src/main/java/androidx/room/RoomDatabase.java is using ConcurrentHashMap which has an issue on Android’s Lollipop release that can lead to lost updates under thread contention. This is further complicated by the fact that we face issues with drops to other repos that forbid its use.
We recommend moving away from it. A possible solution is to use a synchronized map (https://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#synchronizedMap%28java.util.Map%29 ).