Fix race in task creation
Use synchronized blocks instead of a concurrent hash map, as there was
a very subtle race with the concurrent map.
The map of running tasks itself was thread-safe, but the TaskHolder
objects were not. There was a very small timing window in which a
TaskHolder may have been inserted into the table before the task ref
was saved away. This meant another thread could call a method like
cancelGetKey, lookup a valid TaskHolder, then get a null reference
when accessing TaskHolder.task. Using a synchronized block to serialize
the entire task creation process closes this window.
Test: RkpdAppUnitTests
Bug: 264567325
Change-Id: I9da92a12b8112a8c7b7ee51f6e53c5e3bf449fe2
1 file changed