Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
improve
  • Loading branch information
lcian committed Sep 23, 2025
commit fefa6044605d7e7014874d6345ecdc2050b77077
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,7 @@
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import io.sentry.DateUtils;
import io.sentry.EventProcessor;
import io.sentry.Hint;
import io.sentry.IpAddressUtils;
import io.sentry.NoOpLogger;
import io.sentry.SentryAttributeType;
import io.sentry.SentryBaseEvent;
import io.sentry.SentryEvent;
import io.sentry.SentryLevel;
import io.sentry.SentryLogEvent;
import io.sentry.SentryLogEventAttributeValue;
import io.sentry.SentryReplayEvent;
import io.sentry.*;
import io.sentry.android.core.internal.util.AndroidThreadChecker;
import io.sentry.android.core.performance.AppStartMetrics;
import io.sentry.android.core.performance.TimeSpan;
Expand Down Expand Up @@ -66,15 +55,16 @@ public DefaultAndroidEventProcessor(
// don't ref. to method reference, theres a bug on it
// noinspection Convert2MethodRef
// some device info performs disk I/O, but it's result is cached, let's pre-cache it
@Nullable Future<DeviceInfoUtil> deviceInfoUtil;
final @NotNull ExecutorService executorService = Executors.newSingleThreadExecutor();
try {
this.deviceInfoUtil =
deviceInfoUtil =
executorService.submit(() -> DeviceInfoUtil.getInstance(this.context, options));
} catch (RejectedExecutionException e) {
options
.getLogger()
.log(SentryLevel.WARNING, "Device info caching task rejected.", e);
deviceInfoUtil = null;
options.getLogger().log(SentryLevel.WARNING, "Device info caching task rejected.", e);
}
this.deviceInfoUtil = deviceInfoUtil;
executorService.shutdown();
}

Expand Down
2 changes: 0 additions & 2 deletions sentry/src/main/java/io/sentry/Scopes.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import io.sentry.util.SpanUtils;
import io.sentry.util.TracingUtils;
import java.io.Closeable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.RejectedExecutionException;
import org.jetbrains.annotations.ApiStatus;
Expand Down
15 changes: 10 additions & 5 deletions sentry/src/main/java/io/sentry/SentryExecutorService.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public SentryExecutorService() {
}

@Override
public @NotNull Future<?> submit(final @NotNull Runnable runnable) throws RejectedExecutionException {
public @NotNull Future<?> submit(final @NotNull Runnable runnable)
throws RejectedExecutionException {
if (executorService.getQueue().size() < MAX_QUEUE_SIZE) {
return executorService.submit(runnable);
}
Expand All @@ -67,7 +68,8 @@ public SentryExecutorService() {
}

@Override
public @NotNull <T> Future<T> submit(final @NotNull Callable<T> callable) throws RejectedExecutionException {
public @NotNull <T> Future<T> submit(final @NotNull Callable<T> callable)
throws RejectedExecutionException {
if (executorService.getQueue().size() < MAX_QUEUE_SIZE) {
return executorService.submit(callable);
}
Expand All @@ -80,7 +82,8 @@ public SentryExecutorService() {
}

@Override
public @NotNull Future<?> schedule(final @NotNull Runnable runnable, final long delayMillis) throws RejectedExecutionException {
public @NotNull Future<?> schedule(final @NotNull Runnable runnable, final long delayMillis)
throws RejectedExecutionException {
if (executorService.getQueue().size() < MAX_QUEUE_SIZE) {
return executorService.schedule(runnable, delayMillis, TimeUnit.MILLISECONDS);
}
Expand Down Expand Up @@ -124,10 +127,12 @@ public void prewarm() {
executorService.submit(
() -> {
try {
// schedule a bunch of dummy runnables in the future that will never execute to trigger
// schedule a bunch of dummy runnables in the future that will never execute to
// trigger
// queue growth and then purge the queue
for (int i = 0; i < INITIAL_QUEUE_SIZE; i++) {
final Future<?> future = executorService.schedule(dummyRunnable, 365L, TimeUnit.DAYS);
final Future<?> future =
executorService.schedule(dummyRunnable, 365L, TimeUnit.DAYS);
future.cancel(true);
}
executorService.purge();
Expand Down