Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ private void sendChunks(final @NotNull IScopes scopes, final @NotNull SentryOpti
scopes.captureProfileChunk(payload);
}
});
} catch (Throwable e) {
} catch (RejectedExecutionException e) {
options.getLogger().log(SentryLevel.DEBUG, "Failed to send profile chunks.", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.sentry.SentryLevel;
import io.sentry.SentryOptions;
import io.sentry.logger.LoggerBatchProcessor;
import java.util.concurrent.RejectedExecutionException;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -38,7 +39,7 @@ public void run() {
flush(LoggerBatchProcessor.FLUSH_AFTER_MS);
}
});
} catch (Throwable t) {
} catch (RejectedExecutionException t) {
options.getLogger().log(SentryLevel.ERROR, t, "Failed to submit log flush in onBackground()");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.sentry.SentryLevel;
import io.sentry.SentryOptions;
import io.sentry.metrics.MetricsBatchProcessor;
import java.util.concurrent.RejectedExecutionException;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -38,7 +39,7 @@ public void run() {
flush(MetricsBatchProcessor.FLUSH_AFTER_MS);
}
});
} catch (Throwable t) {
} catch (RejectedExecutionException t) {
options
.getLogger()
.log(SentryLevel.ERROR, t, "Failed to submit metrics flush in onBackground()");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,9 @@ public void onFrameMetricCollected(
isRunning = true;
return new ProfileStartData(
profileStartNanos, profileStartCpuMillis, profileStartTimestamp);
} catch (Throwable e) {
} catch (RuntimeException e) {
// Debug reports trace file problems with a plain RuntimeException, so there is no
// narrower type to catch. The profile is not started.
endAndCollect(false, null);
logger.log(SentryLevel.ERROR, "Unable to start a profile: ", e);
isRunning = false;
Expand All @@ -237,7 +239,10 @@ public void onFrameMetricCollected(
// wrapped, so this should never happen (except for tests, where this is the only method
// that throws)
Debug.stopMethodTracing();
} catch (Throwable e) {
} catch (RuntimeException e) {
// Debug reports trace file problems with a plain RuntimeException, so there is no
// narrower type to catch. The profiler is still marked as stopped, and whatever the trace
// file holds is collected.
logger.log(SentryLevel.ERROR, "Error while stopping profiling: ", e);
} finally {
isRunning = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.sentry.util.Objects;
import java.io.Closeable;
import java.io.IOException;
import java.util.concurrent.RejectedExecutionException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
Expand Down Expand Up @@ -74,7 +75,7 @@ private void register(
}
}
});
} catch (Throwable e) {
} catch (RejectedExecutionException e) {
options
.getLogger()
.log(SentryLevel.DEBUG, "Failed to start AnrIntegration on executor thread.", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.util.concurrent.RejectedExecutionException;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -88,7 +89,7 @@ public void register(@NotNull IScopes scopes, @NotNull SentryOptions options) {
.submit(
new ApplicationExitInfoHistoryDispatcher(
context, scopes, this.options, dateProvider, new AnrV2Policy(this.options)));
} catch (Throwable e) {
} catch (RejectedExecutionException e) {
options.getLogger().log(SentryLevel.DEBUG, "Failed to start ANR processor.", e);
}
options.getLogger().log(SentryLevel.DEBUG, "AnrV2Integration installed.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.Closeable;
import java.io.IOException;
import java.util.Locale;
import java.util.concurrent.RejectedExecutionException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -173,7 +174,7 @@ private void executeInBackground(final @NotNull Runnable runnable) {
if (options != null) {
try {
options.getExecutorService().submit(runnable);
} catch (Throwable t) {
} catch (RejectedExecutionException t) {
options
.getLogger()
.log(SentryLevel.ERROR, t, "Failed to submit app components breadcrumb task");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private boolean sampleReplay(
event.getEventId());
return false;
}
} catch (Throwable e) {
} catch (NumberFormatException e) {
options.getLogger().log(SentryLevel.ERROR, "Error parsing replay sample rate.", e);
return false;
}
Expand Down Expand Up @@ -468,7 +468,7 @@ private void setAppVersionAndBuild(final @NotNull SentryBaseEvent event) {
app.setAppVersion(versionName);
app.setAppBuild(versionCode);
event.getContexts().setApp(app);
} catch (Throwable e) {
} catch (IndexOutOfBoundsException e) {
options
.getLogger()
.log(SentryLevel.WARNING, "Failed to parse release from scope cache: %s", release);
Expand Down Expand Up @@ -699,7 +699,9 @@ private void mergeUser(final @NotNull SentryBaseEvent event) {
private @Nullable String getDeviceId() {
try {
return Installation.id(context);
} catch (Throwable e) {
} catch (RuntimeException e) {
// Installation.id wraps file errors in a plain RuntimeException, so there is no narrower
// type to catch. The event is sent without a user id and a device id.
options.getLogger().log(SentryLevel.ERROR, "Error getting installationId.", e);
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public int getSdkInfoVersion() {
|| Build.PRODUCT.contains("vbox86p")
|| Build.PRODUCT.contains("emulator")
|| Build.PRODUCT.contains("simulator");
} catch (Throwable e) {
} catch (NullPointerException e) {
// Build fields are only null off-device, e.g. in unit tests against the android.jar stubs
logger.log(
SentryLevel.ERROR, "Error checking whether application is running in an emulator.", e);
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,8 @@ public static boolean appIsLibraryForComposePreview(final @NotNull Context conte
static @Nullable String getFamily(final @NotNull ILogger logger) {
try {
return Build.MODEL.split(" ", -1)[0];
} catch (Throwable e) {
} catch (NullPointerException e) {
// Build fields are only null off-device, e.g. in unit tests against the android.jar stubs
logger.log(SentryLevel.ERROR, "Error getting device family.", e);
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
Expand Down Expand Up @@ -210,7 +211,10 @@ private void mergeOS(final @NotNull SentryBaseEvent event) {
final OperatingSystem androidOS = deviceInfoUtil.get().getOperatingSystem();
// make Android OS the main OS using the 'os' key
event.getContexts().setOperatingSystem(androidOS);
} catch (Throwable e) {
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
options.getLogger().log(SentryLevel.ERROR, "Failed to retrieve os system", e);
} catch (ExecutionException e) {
options.getLogger().log(SentryLevel.ERROR, "Failed to retrieve os system", e);
}
} else {
Expand Down Expand Up @@ -310,7 +314,10 @@ private void setPackageInfo(final @NotNull SentryBaseEvent event, final @NotNull
if (this.deviceInfoUtil != null) {
try {
deviceInfoUtil = this.deviceInfoUtil.get();
} catch (Throwable e) {
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
options.getLogger().log(SentryLevel.ERROR, "Failed to retrieve device info", e);
} catch (ExecutionException e) {
options.getLogger().log(SentryLevel.ERROR, "Failed to retrieve device info", e);
}
} else {
Expand Down Expand Up @@ -367,7 +374,10 @@ private void setSideLoadedInfo(final @NotNull SentryBaseEvent event) {
event.setTag(entry.getKey(), entry.getValue());
}
}
} catch (Throwable e) {
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
options.getLogger().log(SentryLevel.ERROR, "Error getting side loaded info.", e);
} catch (ExecutionException e) {
options.getLogger().log(SentryLevel.ERROR, "Error getting side loaded info.", e);
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,9 @@ private long getUnusedExternalStorage(final @NotNull StatFs stat) {
private String getDeviceId() {
try {
return Installation.id(context);
} catch (Throwable e) {
} catch (RuntimeException e) {
// Installation.id wraps file errors in a plain RuntimeException, so there is no narrower
// type to catch. The device context is sent without an id.
options.getLogger().log(SentryLevel.ERROR, "Error getting installationId.", e);
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.sentry.util.Objects;
import java.io.Closeable;
import java.io.File;
import java.util.concurrent.RejectedExecutionException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
Expand Down Expand Up @@ -56,7 +57,7 @@ public final void register(final @NotNull IScopes scopes, final @NotNull SentryO
}
}
});
} catch (Throwable e) {
} catch (RejectedExecutionException e) {
logger.log(
SentryLevel.DEBUG,
"Failed to start EnvelopeFileObserverIntegration on executor thread.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.RejectedExecutionException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
Expand Down Expand Up @@ -98,7 +99,7 @@ public synchronized void enableOnShake() {
options
.getExecutorService()
.submit(() -> shakeDetector.init(application, options.getLogger()));
} catch (Throwable t) {
} catch (RejectedExecutionException t) {
options
.getLogger()
.log(SentryLevel.WARNING, "Failed to submit shake detector initialization.", t);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.atomic.AtomicReference;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -415,7 +416,7 @@ private static void deleteCurrentSessionFile(
.submit(() -> {
deleteCurrentSessionFile(options);
});
} catch (Throwable e) {
} catch (RejectedExecutionException e) {
options
.getLogger()
.log(WARNING, "Submission of deletion of the current session file rejected.", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import io.sentry.util.AutoClosableReentrantLock;
import java.util.Date;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -132,7 +133,7 @@ private void scheduleEndSession() {
.getOptions()
.getTimerExecutorService()
.schedule(endSession, sessionEnd.remaining(TimeUnit.MILLISECONDS));
} catch (Throwable e) {
} catch (RejectedExecutionException e) {
scopes
.getOptions()
.getLogger()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public boolean deleteNativeEventFile(final @NotNull NativeEventData nativeEventD
file.getAbsolutePath());
return false;
}
} catch (Throwable e) {
} catch (SecurityException e) {
options
.getLogger()
.log(
Expand Down Expand Up @@ -285,7 +285,7 @@ public boolean deleteNativeEventFile(final @NotNull NativeEventData nativeEventD
break;
}
}
} catch (Throwable e) {
} catch (IOException e) {
options
.getLogger()
.log(
Expand Down Expand Up @@ -337,7 +337,8 @@ public boolean deleteNativeEventFile(final @NotNull NativeEventData nativeEventD
if (NATIVE_PLATFORM.equals(platform) && timestamp != null) {
result = new NativeEnvelopeMetadata(file, timestamp.getTime());
}
} catch (Throwable e) {
} catch (IOException | IllegalStateException e) {
// IllegalStateException is how the JSON reader reports an unexpected token
options
.getLogger()
.log(SentryLevel.DEBUG, e, "Error parsing event JSON from: %s", file.getName());
Expand Down Expand Up @@ -369,7 +370,9 @@ public boolean deleteNativeEventFile(final @NotNull NativeEventData nativeEventD
}
}
}
} catch (Throwable e) {
} catch (Exception e) {
// EnvelopeReader reports a malformed envelope with IllegalArgumentException, and getData()
// is declared to throw Exception for items that are created lazily
options
.getLogger()
.log(SentryLevel.DEBUG, e, "Error loading envelope file: %s", file.getAbsolutePath());
Expand Down Expand Up @@ -420,7 +423,9 @@ private static final class ItemHeaderInfo {
if (length >= 0) {
return new ItemHeaderInfo(type, length);
}
} catch (Throwable e) {
} catch (IOException | IllegalStateException | NumberFormatException e) {
// the JSON reader reports an unexpected token with IllegalStateException, and a length that
// isn't an int with NumberFormatException
options.getLogger().log(SentryLevel.DEBUG, e, "Error parsing item header");
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ private void sendChunk(
} else {
executorServiceSupplier.evaluate().submit(task);
}
} catch (Throwable e) {
} catch (RejectedExecutionException e) {
options.getLogger().log(SentryLevel.DEBUG, "Failed to send profile chunk.", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import io.sentry.util.Objects;
import java.io.Closeable;
import java.io.IOException;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -160,6 +162,13 @@ private void sendCachedEnvelopes(
.getLogger()
.log(
SentryLevel.DEBUG, "Synchronous send interrupted, continuing in the background.");
} catch (ExecutionException e) {
options.getLogger().log(SentryLevel.ERROR, "Failed trying to send cached events.", e);
} catch (CancellationException e) {
// the executor returns a cancelled future instead of throwing when its queue is full
options
.getLogger()
.log(SentryLevel.ERROR, "The executor rejected sending the cached events.", e);
}
}
options.getLogger().log(SentryLevel.DEBUG, "SendCachedEnvelopeIntegration installed.");
Expand All @@ -170,10 +179,6 @@ private void sendCachedEnvelopes(
SentryLevel.ERROR,
"Failed to call the executor. Cached events will not be sent. Did you call Sentry.close()?",
e);
} catch (Throwable e) {
options
.getLogger()
.log(SentryLevel.ERROR, "Failed to call the executor. Cached events will not be sent", e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private void registerReceiver(
}
}
});
} catch (Throwable e) {
} catch (RejectedExecutionException e) {
options
.getLogger()
.log(
Expand Down
Loading
Loading