From f84e5efd3b36711d10c1299905cb4f544333a435 Mon Sep 17 00:00:00 2001 From: Nelson Osacky Date: Wed, 18 Nov 2026 17:17:20 +0100 Subject: [PATCH] test(android): Collect UI test breadcrumbs in a thread-safe list beforeBreadcrumb runs on whichever thread adds the breadcrumb, so the Compose click and swipe tests could read the list while another thread was adding to it. Refs #5513 Refs JAVA-552 Co-Authored-By: Claude Opus 5.5 --- .../java/io/sentry/uitest/android/UserInteractionTests.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sentry-android-integration-tests/sentry-uitest-android/src/androidTest/java/io/sentry/uitest/android/UserInteractionTests.kt b/sentry-android-integration-tests/sentry-uitest-android/src/androidTest/java/io/sentry/uitest/android/UserInteractionTests.kt index 2327fb16a5..ac46028322 100644 --- a/sentry-android-integration-tests/sentry-uitest-android/src/androidTest/java/io/sentry/uitest/android/UserInteractionTests.kt +++ b/sentry-android-integration-tests/sentry-uitest-android/src/androidTest/java/io/sentry/uitest/android/UserInteractionTests.kt @@ -15,6 +15,7 @@ import io.sentry.Breadcrumb import io.sentry.SentryLevel import io.sentry.SentryOptions import io.sentry.android.core.SentryAndroidOptions +import java.util.concurrent.CopyOnWriteArrayList import kotlin.test.Test import kotlin.test.assertTrue import org.hamcrest.CoreMatchers.`is` @@ -31,7 +32,8 @@ class UserInteractionTests : BaseUiTest() { @Test fun composableClickGeneratesMatchingBreadcrumb() { - val breadcrumbs = mutableListOf() + // beforeBreadcrumb runs on whichever thread adds the breadcrumb + val breadcrumbs = CopyOnWriteArrayList() initSentryAndCollectBreadcrumbs(breadcrumbs) val activity = launchActivity() @@ -65,7 +67,8 @@ class UserInteractionTests : BaseUiTest() { @Test fun composableSwipeGeneratesMatchingBreadcrumb() { - val breadcrumbs = mutableListOf() + // beforeBreadcrumb runs on whichever thread adds the breadcrumb + val breadcrumbs = CopyOnWriteArrayList() initSentryAndCollectBreadcrumbs(breadcrumbs) val activity = launchActivity()