Fixes a thread safety issue (a time-of-check-time-of-use bug) in BatteryExternalStatsWorker that causes system_server crashes in VROS device.
Synchronize BatteryExternalStatsWorker.shutdown(). Without this, a shutdown can sneak in-between the checks to mExecutor.isShutdown() and other mExecutor calls, causing the later calls to fail with a RejectedExecutionException instead of having the intended behavior for a shutdown mExecutor. Test: There is no known test case for regression testing. This is a race condition, so any test case would inherently be flaky. The correctness of the patch is easily seen by observing the time-of-check-time-of-use issues that arise throughout BatteryExternalStatsWorker.java before the patch is applied. Change-Id: Id690f3451f86ac536b186021ef4fb63827bc863e
This commit is contained in:
@@ -399,7 +399,7 @@ class BatteryExternalStatsWorker implements BatteryStatsImpl.ExternalStatsSync {
|
||||
}
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
public synchronized void shutdown() {
|
||||
mExecutorService.shutdownNow();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user