Commit 7a66f3b5 authored by Bo Liu's avatar Bo Liu Committed by Commit Bot

android: Fix PostTask ConcurrentModificationException

Calling initNativeTaskRunner might back into
registerPreNativeTaskRunnerLocked which causes
ConcurrentModificationException in WeakHashMap.

Fix by setting sPreNativeTaskRunners to null first.
onNativeSchedulerReady indicates native side is already ready, so should
be safe to set sPreNativeTaskRunners to null.

Bug: 974674
Change-Id: I77ea44c2b9d8a060c4b60e9c9171d14c91b71f7d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1660971Reviewed-by: default avatarAlex Clarke <alexclarke@chromium.org>
Commit-Queue: Bo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#669664}
parent ccf4aac9
...@@ -239,10 +239,11 @@ public class PostTask { ...@@ -239,10 +239,11 @@ public class PostTask {
@CalledByNative @CalledByNative
private static void onNativeSchedulerReady() { private static void onNativeSchedulerReady() {
synchronized (sLock) { synchronized (sLock) {
for (TaskRunner taskRunner : sPreNativeTaskRunners) { Set<TaskRunner> preNativeTaskRunners = sPreNativeTaskRunners;
sPreNativeTaskRunners = null;
for (TaskRunner taskRunner : preNativeTaskRunners) {
taskRunner.initNativeTaskRunner(); taskRunner.initNativeTaskRunner();
} }
sPreNativeTaskRunners = null;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment