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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
### Internal

- Measure the 30 second performance-collection budget on a monotonic ticker, so that a device time change no longer ends collection early or extends it past the budget ([#6101](https://github.com/getsentry/sentry-java/pull/6101))
- Narrow `catch (Throwable)` to the exceptions the guarded code throws, so SDK bugs and fatal errors are no longer swallowed ([#6564](https://github.com/getsentry/sentry-java/pull/6564))

## 8.63.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,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 @@ -37,7 +38,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 @@ -37,7 +38,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,7 @@ public void onFrameMetricCollected(
isRunning = true;
return new ProfileStartData(
profileStartNanos, profileStartCpuMillis, profileStartTimestamp);
} catch (Throwable e) {
} catch (RuntimeException e) {
endAndCollect(false, null);
logger.log(SentryLevel.ERROR, "Unable to start a profile: ", e);
isRunning = false;
Expand All @@ -237,7 +237,7 @@ 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) {
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 @@ -75,7 +76,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 @@ -87,7 +88,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 Expand Up @@ -203,7 +204,7 @@ public void markReported(final long timestamp) {
return new ParseResult(ParseResult.Type.NO_DUMP);
}
dump = NativeEventUtils.readBytes(trace);
} catch (Throwable e) {
} catch (IOException e) {
options.getLogger().log(SentryLevel.WARNING, "Failed to read ANR thread dump", e);
return new ParseResult(ParseResult.Type.NO_DUMP);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,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 @@ -467,7 +467,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 @@ -698,7 +698,7 @@ private void mergeUser(final @NotNull SentryBaseEvent event) {
private @Nullable String getDeviceId() {
try {
return Installation.id(context);
} catch (Throwable e) {
} catch (RuntimeException e) {
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 @@ -485,7 +485,7 @@ private Long getUnusedExternalStorage(final @NotNull StatFs stat) {
private String getDeviceId() {
try {
return Installation.id(context);
} catch (Throwable e) {
} catch (RuntimeException e) {
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 @@ -97,7 +98,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 @@ -419,7 +420,7 @@ private static void deleteCurrentSessionFile(
() -> {
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 @@ -131,7 +132,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
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,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,7 @@
import io.sentry.util.Objects;
import java.io.Closeable;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -157,6 +158,14 @@ private void sendCachedEnvelopes(
options
.getLogger()
.log(SentryLevel.DEBUG, "Synchronous send timed out, continuing in the background.");
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
options
.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);
}
}
options.getLogger().log(SentryLevel.DEBUG, "SendCachedEnvelopeIntegration installed.");
Expand All @@ -167,10 +176,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 @@ -187,7 +187,7 @@ private void registerReceiver(
}
}
});
} catch (Throwable e) {
} catch (RejectedExecutionException e) {
options
.getLogger()
.log(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import java.time.Instant;
import java.time.format.DateTimeFormatter;
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 @@ -98,7 +99,7 @@ public void register(@NotNull IScopes scopes, @NotNull SentryOptions options) {
this.options,
dateProvider,
new TombstonePolicy(this.options, this.context)));
} catch (Throwable e) {
} catch (RejectedExecutionException e) {
options.getLogger().log(SentryLevel.DEBUG, "Failed to start tombstone processor.", e);
}
options.getLogger().log(SentryLevel.DEBUG, "TombstoneIntegration installed.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ private static void performRotationIfNeeded(final @NotNull File cacheDir) {

try {
oldFile.delete();
} catch (Throwable e) {
} catch (SecurityException e) {
// ignored
}

try {
currentFile.renameTo(oldFile);
} catch (Throwable e) {
} catch (SecurityException e) {
// ignored
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -143,7 +144,7 @@ public void close() throws IOException {
logger.log(SentryLevel.WARNING, "Failed to close AnrProfileManager");
}
});
} catch (Throwable e) {
} catch (RejectedExecutionException e) {
logger.log(SentryLevel.WARNING, "Failed to submit AnrProfileManager close");
}
}
Expand Down
Loading
Loading