Skip to content

Commit

Permalink
fix(app, android): correct TaskExecutor shutdown error
Browse files Browse the repository at this point in the history
Access to the collection of TaskExecutors wasn't correctly synchronized
in all places

Fixes #5225
  • Loading branch information
mikehardy committed Apr 28, 2021
1 parent ce4588f commit 1663504
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
*
*/

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.RejectedExecutionHandler;
Expand Down Expand Up @@ -96,12 +97,14 @@ public String getExecutorName(boolean isTransactional, String identifier) {
}

public void shutdown() {
Set<String> existingExecutorNames = executors.keySet();
for (String executorName : existingExecutorNames) {
if (!executorName.startsWith(name)) {
existingExecutorNames.remove(executorName);
} else {
removeExecutor(executorName);
synchronized(executors) {
List<String> existingExecutorNames = new ArrayList<>(executors.keySet());
for (String executorName : existingExecutorNames) {
if (!executorName.startsWith(name)) {
executors.remove(executorName);
} else {
removeExecutor(executorName);
}
}
}
}
Expand Down

0 comments on commit 1663504

Please sign in to comment.