summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Aditya <adityasngh@google.com> 2024-09-10 15:12:01 +0000
committer Aditya <adityasngh@google.com> 2024-09-23 03:58:06 +0000
commit0a24f333de4583ff8913ede5cd96ce4ce38ccd62 (patch)
tree7e8796f1d19746180fcc8013833a15333cd865f7
parent56ee25a270975177c87910fe968f14e41cb2c0fc (diff)
Fix for kernal panic caused by large number of threads.
The problem is triggered by the broadcast received durint app uninstall, resulting in DocsUi creating thread pools faster than they can exit. To fix this, `CachedThreadPool` has been replaced by a static `FixedThreadPool` of 10 threads. Bug: 365682930 Test: Samsung QA Flag: EXEMPT bugfix Change-Id: I0017151d1141f0d2ddf04925b68619d73a241997
-rw-r--r--src/com/android/documentsui/roots/ProvidersCache.java8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/com/android/documentsui/roots/ProvidersCache.java b/src/com/android/documentsui/roots/ProvidersCache.java
index a0e813e0a..bc54fce83 100644
--- a/src/com/android/documentsui/roots/ProvidersCache.java
+++ b/src/com/android/documentsui/roots/ProvidersCache.java
@@ -62,7 +62,6 @@ import com.android.modules.utils.build.SdkLevel;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
-import com.google.common.util.concurrent.MoreExecutors;
import java.util.ArrayList;
import java.util.Collection;
@@ -76,7 +75,6 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Semaphore;
-import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
@@ -95,6 +93,9 @@ public class ProvidersCache implements ProvidersAccess, LookupApplicationName {
// ArchivesProvider doesn't support any roots.
ArchivesProvider.AUTHORITY);
private static final int FIRST_LOAD_TIMEOUT_MS = 5000;
+ private static final int NUM_THREADS = 10;
+ private static final ExecutorService ASYNC_TASKS_THREAD_POOL =
+ Executors.newFixedThreadPool(NUM_THREADS);
private final Context mContext;
@@ -562,8 +563,7 @@ public class ProvidersCache implements ProvidersAccess, LookupApplicationName {
if (!taskInfos.isEmpty()) {
CountDownLatch updateTaskInternalCountDown = new CountDownLatch(taskInfos.size());
- ExecutorService executor = MoreExecutors.getExitingExecutorService(
- (ThreadPoolExecutor) Executors.newCachedThreadPool());
+ ExecutorService executor = ASYNC_TASKS_THREAD_POOL;
for (SingleProviderUpdateTaskInfo taskInfo : taskInfos) {
executor.submit(() ->
startSingleProviderUpdateTask(