From a2ba7e83074d6cbfdc08b42a9773b7666ccf9751 Mon Sep 17 00:00:00 2001 From: Nelson Osacky Date: Wed, 18 Nov 2026 17:16:51 +0100 Subject: [PATCH] ref: Remove Throwable catches that guard nothing The catches in ClientReportRecorder.recordLostEnvelope and recordLostEvent wrap callees that already catch their own failures, and the one in ContextUtils wraps a read of split APK info that DeviceInfoUtil has already cached. Refs #5513 Refs JAVA-552 Co-Authored-By: Claude Opus 5.5 --- .../io/sentry/android/core/ContextUtils.java | 14 +++++--------- .../clientreport/ClientReportRecorder.java | 16 ++++------------ 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/sentry-android-core/src/main/java/io/sentry/android/core/ContextUtils.java b/sentry-android-core/src/main/java/io/sentry/android/core/ContextUtils.java index 22938712faf..3dbc1960fbc 100644 --- a/sentry-android-core/src/main/java/io/sentry/android/core/ContextUtils.java +++ b/sentry-android-core/src/main/java/io/sentry/android/core/ContextUtils.java @@ -506,16 +506,12 @@ static void setAppPackageInfo( app.setPermissions(permissions); if (deviceInfoUtil != null) { - try { - final ContextUtils.SplitApksInfo splitApksInfo = deviceInfoUtil.getSplitApksInfo(); - if (splitApksInfo != null) { - app.setSplitApks(splitApksInfo.isSplitApks()); - if (splitApksInfo.getSplitNames() != null) { - app.setSplitNames(Arrays.asList(splitApksInfo.getSplitNames())); - } + final ContextUtils.SplitApksInfo splitApksInfo = deviceInfoUtil.getSplitApksInfo(); + if (splitApksInfo != null) { + app.setSplitApks(splitApksInfo.isSplitApks()); + if (splitApksInfo.getSplitNames() != null) { + app.setSplitNames(Arrays.asList(splitApksInfo.getSplitNames())); } - } catch (Throwable e) { - // Split APK info is optional, the app context is still complete without it. } } } diff --git a/sentry/src/main/java/io/sentry/clientreport/ClientReportRecorder.java b/sentry/src/main/java/io/sentry/clientreport/ClientReportRecorder.java index ba6d60e2563..57d8f8f3393 100644 --- a/sentry/src/main/java/io/sentry/clientreport/ClientReportRecorder.java +++ b/sentry/src/main/java/io/sentry/clientreport/ClientReportRecorder.java @@ -58,12 +58,8 @@ public void recordLostEnvelope(@NotNull DiscardReason reason, @Nullable SentryEn return; } - try { - for (final SentryEnvelopeItem item : envelope.getItems()) { - recordLostEnvelopeItem(reason, item); - } - } catch (Throwable e) { - options.getLogger().log(SentryLevel.ERROR, e, "Unable to record lost envelope."); + for (final SentryEnvelopeItem item : envelope.getItems()) { + recordLostEnvelopeItem(reason, item); } } @@ -137,12 +133,8 @@ public void recordLostEvent(@NotNull DiscardReason reason, @NotNull DataCategory @Override public void recordLostEvent( @NotNull DiscardReason reason, @NotNull DataCategory category, long count) { - try { - recordLostEventInternal(reason.getReason(), category.getCategory(), count); - executeOnDiscard(reason, category, count); - } catch (Throwable e) { - options.getLogger().log(SentryLevel.ERROR, e, "Unable to record lost event."); - } + recordLostEventInternal(reason.getReason(), category.getCategory(), count); + executeOnDiscard(reason, category, count); } private void executeOnDiscard(