Skip to content

Commit 83277d1

Browse files
runningcodeclaude
andauthored
fix(android): Name the device-info caching thread (#5684)
* fix(android): Name the device-info caching thread DefaultAndroidEventProcessor created its device-info pre-caching executor via Executors.newSingleThreadExecutor() with no ThreadFactory, so the JDK named the thread pool-N-thread-M and it was not identifiable as an SDK thread. Supply a ThreadFactory that names it SentryDeviceInfoCache, matching the convention used elsewhere in the SDK. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * changelog --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 34c912a commit 83277d1

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Fixes
6+
7+
- Name the device-info caching thread `SentryDeviceInfoCache` so all threads spawned by the SDK are identifiable ([#5684](https://github.com/getsentry/sentry-java/pull/5684))
8+
39
## 8.47.0
410

511
### Behavioral Changes

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.concurrent.Executors;
2828
import java.util.concurrent.Future;
2929
import java.util.concurrent.RejectedExecutionException;
30+
import java.util.concurrent.ThreadFactory;
3031
import org.jetbrains.annotations.NotNull;
3132
import org.jetbrains.annotations.Nullable;
3233
import org.jetbrains.annotations.TestOnly;
@@ -56,7 +57,8 @@ public DefaultAndroidEventProcessor(
5657
// noinspection Convert2MethodRef
5758
// some device info performs disk I/O, but it's result is cached, let's pre-cache it
5859
@Nullable Future<DeviceInfoUtil> deviceInfoUtil;
59-
final @NotNull ExecutorService executorService = Executors.newSingleThreadExecutor();
60+
final @NotNull ExecutorService executorService =
61+
Executors.newSingleThreadExecutor(new DeviceInfoCacheThreadFactory());
6062
try {
6163
deviceInfoUtil =
6264
executorService.submit(() -> DeviceInfoUtil.getInstance(this.context, options));
@@ -425,4 +427,13 @@ private void setSideLoadedInfo(final @NotNull SentryBaseEvent event) {
425427
public @Nullable Long getOrder() {
426428
return 8000L;
427429
}
430+
431+
private static final class DeviceInfoCacheThreadFactory implements ThreadFactory {
432+
@Override
433+
public @NotNull Thread newThread(final @NotNull Runnable r) {
434+
final Thread ret = new Thread(r, "SentryDeviceInfoCache");
435+
ret.setDaemon(true);
436+
return ret;
437+
}
438+
}
428439
}

0 commit comments

Comments
 (0)