Skip to content

Conversation

@jpnurmi
Copy link
Collaborator

@jpnurmi jpnurmi commented Sep 10, 2025

Java runtime exceptions are caught in two layers:

  • Sentry Java SDK
  • .NET Java Interop (JNI)

For example, the result of exactly one CrashType.JavaThread and one CrashType.JavaBackgroundThread:

Before: 2+2 ❌ After: 1+1 ✅
image Screenshot From 2025-09-10 12-46-30

Fixes: #4237

@jpnurmi jpnurmi changed the title fix: duplicate Java.Lang.RuntimeException on Android fix: de-duplicate Java.Lang.RuntimeException on Android Sep 10, 2025
@jpnurmi jpnurmi marked this pull request as ready for review September 10, 2025 12:28
options.EnableScopeSync = true;
options.ScopeObserver = new AndroidScopeObserver(options);
// Don't capture Java Runtime exceptions in the managed SDK, since we already capture them in the native SDK
options.AddExceptionFilterForType<Java.Lang.RuntimeException>();
Copy link
Member

@Flash0ver Flash0ver Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: test

Is there a (somewhat) straightforward way to (unit) test the suppression of the double capture?

Perhaps via

#if ANDROID
    SentrySdk.CauseCrash(CrashType.Java);
#endif

or would this need to be an integration test?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find any suitable place for testing this. Native SDKs are not initialized in unit tests, and integration tests only run on desktop platforms. Once we have the infrastructure for e2e tests, though, then we can hopefully start testing these things:

Copy link
Collaborator

@jamescrosswell jamescrosswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thank you!

@jamescrosswell jamescrosswell merged commit aab708f into main Sep 10, 2025
36 checks passed
@jamescrosswell jamescrosswell deleted the fix/duplicate-java-runtime-exception branch September 10, 2025 22:29
This was referenced Sep 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

On .NET 9, Java exception on background thread double reports

4 participants