Skip to content

Commit 8e27d0c

Browse files
runningcodeclaude
andcommitted
ref(android): Catch only expected exceptions when parsing profiling config
Narrow the deserialization catch from Throwable to Exception. The vendored JSON reader signals bad input with IOException (MalformedJsonException, EOFException), IllegalStateException on token type mismatch, and NumberFormatException on an unparseable number — all Exception subclasses. Catching Throwable additionally swallowed Error, which is never a recoverable "config file is bad" signal. This also restores parity with JsonSerializer.deserialize, which catches Exception, so the replaced behaviour is matched exactly rather than widened. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent eef22e7 commit 8e27d0c

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

sentry-android-core/src/main/java/io/sentry/android/core/SentryPerformanceProvider.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,17 @@ private void launchAppStartProfiler(final @NotNull AppStartMetrics appStartMetri
172172
* them.
173173
*
174174
* <p>Returns null on malformed input, matching what {@code JsonSerializer.deserialize} did, so
175-
* callers keep reporting it as a deserialization failure rather than a read error.
175+
* callers keep reporting it as a deserialization failure rather than a read error. The vendored
176+
* JSON reader signals bad input with {@link java.io.IOException} (including {@code
177+
* MalformedJsonException} and {@code EOFException}), {@link IllegalStateException} on a token
178+
* type mismatch, and {@link NumberFormatException} on an unparseable number — all {@link
179+
* Exception} subclasses, so {@code Error} propagates instead of being swallowed here.
176180
*/
177181
private @Nullable SentryAppStartProfilingOptions deserializeProfilingConfig(
178182
final @NotNull Reader reader) {
179183
try (final @NotNull JsonObjectReader jsonReader = new JsonObjectReader(reader)) {
180184
return new SentryAppStartProfilingOptions.Deserializer().deserialize(jsonReader, logger);
181-
} catch (Throwable e) {
185+
} catch (Exception e) {
182186
logger.log(SentryLevel.ERROR, "Error when deserializing", e);
183187
return null;
184188
}

0 commit comments

Comments
 (0)