Skip to content

Commit

Permalink
Fix: Do not crash when event processors throw a lower level Throwable…
Browse files Browse the repository at this point in the history
… class (#1800)
  • Loading branch information
marandaneto authored Nov 11, 2021
1 parent d167f5a commit e1c72cf
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

* Feat: Add `graphql-java` instrumentation (#1777)
* Fix: Do not crash when event processors throw a lower level Throwable class (#1800)
* Fix: ActivityFramesTracker does not throw if Activity has no observers (#1799)

## 5.3.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static io.sentry.android.core.ActivityLifecycleIntegration.UI_LOAD_OP;

import io.sentry.EventProcessor;
import io.sentry.SentryEvent;
import io.sentry.SpanContext;
import io.sentry.protocol.MeasurementValue;
import io.sentry.protocol.SentryId;
Expand Down Expand Up @@ -32,6 +33,22 @@ final class PerformanceAndroidEventProcessor implements EventProcessor {
Objects.requireNonNull(activityFramesTracker, "ActivityFramesTracker is required");
}

/**
* Returns the event itself
*
* @param event the SentryEvent the SentryEvent
* @param hint the Hint the Hint
* @return returns the event itself
*/
@Override
@Nullable
public SentryEvent process(@NotNull SentryEvent event, @Nullable Object hint) {
// that's only necessary because on newer versions of Unity, if not overriding this method, it's
// throwing 'java.lang.AbstractMethodError: abstract method' and the reason is probably
// compilation mismatch.
return event;
}

@Override
public synchronized @NotNull SentryTransaction process(
@NotNull SentryTransaction transaction, @Nullable Object hint) {
Expand Down
4 changes: 2 additions & 2 deletions sentry/src/main/java/io/sentry/SentryClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ private SentryEvent processEvent(
for (final EventProcessor processor : eventProcessors) {
try {
event = processor.process(event, hint);
} catch (Exception e) {
} catch (Throwable e) {
options
.getLogger()
.log(
Expand Down Expand Up @@ -235,7 +235,7 @@ private SentryTransaction processTransaction(
for (final EventProcessor processor : eventProcessors) {
try {
transaction = processor.process(transaction, hint);
} catch (Exception e) {
} catch (Throwable e) {
options
.getLogger()
.log(
Expand Down
3 changes: 1 addition & 2 deletions sentry/src/test/java/io/sentry/SentryClientTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import java.io.IOException
import java.io.InputStreamReader
import java.lang.IllegalArgumentException
import java.lang.IllegalStateException
import java.lang.RuntimeException
import java.nio.charset.Charset
import java.util.Arrays
import java.util.UUID
Expand Down Expand Up @@ -1299,7 +1298,7 @@ class SentryClientTest {
private fun eventProcessorThrows(): EventProcessor {
return object : EventProcessor {
override fun process(event: SentryEvent, hint: Any?): SentryEvent? {
throw RuntimeException()
throw Throwable()
}
}
}
Expand Down

0 comments on commit e1c72cf

Please sign in to comment.