Skip to content

Commit 7fa2d10

Browse files
ref(android): Catch only what readEnvelope can throw
The envelope reader declares IOException and rejects malformed payloads with an unchecked IllegalArgumentException, so name both instead of catching Exception. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 960c618 commit 7fa2d10

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎sentry-android-core/src/main/java/io/sentry/android/core/InternalSentrySdk.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,15 +314,15 @@ private enum EnvelopeEventState {
314314
}
315315

316316
/**
317-
* Reads an envelope from the given bytes. Besides the declared {@link IOException}, {@link
318-
* io.sentry.IEnvelopeReader#read(InputStream)} also rejects malformed payloads with an unchecked
319-
* {@link IllegalArgumentException}, hence the broader catch.
317+
* Reads an envelope from the given bytes. {@link io.sentry.IEnvelopeReader#read(InputStream)}
318+
* declares {@link IOException} and additionally rejects malformed payloads with an unchecked
319+
* {@link IllegalArgumentException}.
320320
*/
321321
private static @Nullable SentryEnvelope readEnvelope(
322322
final @NotNull SentryOptions options, final @NotNull byte[] envelopeData) {
323323
try (final InputStream envelopeInputStream = new ByteArrayInputStream(envelopeData)) {
324324
return options.getEnvelopeReader().read(envelopeInputStream);
325-
} catch (Exception e) {
325+
} catch (IOException | IllegalArgumentException e) {
326326
options.getLogger().log(SentryLevel.ERROR, "Failed to read envelope", e);
327327
return null;
328328
}

0 commit comments

Comments
 (0)