Skip to content

Commit 79f6fbc

Browse files
committed
perf(android): Reuse SentryExecutorService for DeviceInfoUtil pre-caching
Replace Executors.newSingleThreadExecutor() with options.getExecutorService() in DefaultAndroidEventProcessor to avoid creating a dedicated thread during init. The SDK already has an executor service available.
1 parent 81d2815 commit 79f6fbc

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

sentry-android-core/src/main/java/io/sentry/android/core/DefaultAndroidEventProcessor.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import java.util.List;
2424
import java.util.Locale;
2525
import java.util.Map;
26-
import java.util.concurrent.ExecutorService;
27-
import java.util.concurrent.Executors;
2826
import java.util.concurrent.Future;
2927
import java.util.concurrent.RejectedExecutionException;
3028
import org.jetbrains.annotations.NotNull;
@@ -56,16 +54,16 @@ public DefaultAndroidEventProcessor(
5654
// noinspection Convert2MethodRef
5755
// some device info performs disk I/O, but it's result is cached, let's pre-cache it
5856
@Nullable Future<DeviceInfoUtil> deviceInfoUtil;
59-
final @NotNull ExecutorService executorService = Executors.newSingleThreadExecutor();
6057
try {
6158
deviceInfoUtil =
62-
executorService.submit(() -> DeviceInfoUtil.getInstance(this.context, options));
59+
options
60+
.getExecutorService()
61+
.submit(() -> DeviceInfoUtil.getInstance(this.context, options));
6362
} catch (RejectedExecutionException e) {
6463
deviceInfoUtil = null;
6564
options.getLogger().log(SentryLevel.WARNING, "Device info caching task rejected.", e);
6665
}
6766
this.deviceInfoUtil = deviceInfoUtil;
68-
executorService.shutdown();
6967
}
7068

7169
@Override

0 commit comments

Comments
 (0)