From e69101c0c8cb870200a0149c1475bb921048aaf9 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 18 Jul 2022 18:20:50 +0200 Subject: [PATCH 1/5] use copy to iterate over _breadcrumbs --- dart/lib/src/scope.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dart/lib/src/scope.dart b/dart/lib/src/scope.dart index e0a4fe090..4dc16987f 100644 --- a/dart/lib/src/scope.dart +++ b/dart/lib/src/scope.dart @@ -398,7 +398,7 @@ class Scope { await clone.setExtra(extraKey, _extra[extraKey]); } - for (final breadcrumb in _breadcrumbs) { + for (final breadcrumb in List.from(_breadcrumbs)) { await clone.addBreadcrumb(breadcrumb); } @@ -406,9 +406,9 @@ class Scope { clone.addEventProcessor(eventProcessor); } - contexts.forEach((key, value) { + contexts.forEach((key, value) async { if (value != null) { - clone.setContexts(key, value); + await clone.setContexts(key, value); } }); From 51d3e3d2035dc6777eb0720225bebace665e508d Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Mon, 18 Jul 2022 18:23:53 +0200 Subject: [PATCH 2/5] add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69215c5fc..732614bc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * Breadcrumbs should not be duplicated if there is no mechanism on Android ([#936](https://github.com/getsentry/sentry-dart/pull/936)) * Maps with Key Object, Object would fail during serialization if not String, Object ([#935](https://github.com/getsentry/sentry-dart/pull/935)) +* Fix: Breadcrumbs "Concurrent Modification" ([#948](https://github.com/getsentry/sentry-dart/pull/948)) ### Features From 03e1c0218aa9f5696524ae85f3dc879695948156 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 19 Jul 2022 10:55:09 +0200 Subject: [PATCH 3/5] copy other collections that are beeing iterated and could possibly be modified --- dart/lib/src/scope.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dart/lib/src/scope.dart b/dart/lib/src/scope.dart index 4dc16987f..b58114194 100644 --- a/dart/lib/src/scope.dart +++ b/dart/lib/src/scope.dart @@ -390,11 +390,11 @@ class Scope { await clone.setUser(user); - for (final tag in _tags.keys) { + for (final tag in List.from(_tags.keys)) { await clone.setTag(tag, _tags[tag]!); } - for (final extraKey in _extra.keys) { + for (final extraKey in List.from(_extra.keys)) { await clone.setExtra(extraKey, _extra[extraKey]); } @@ -402,17 +402,17 @@ class Scope { await clone.addBreadcrumb(breadcrumb); } - for (final eventProcessor in _eventProcessors) { + for (final eventProcessor in List.from(_eventProcessors)) { clone.addEventProcessor(eventProcessor); } - contexts.forEach((key, value) async { + Map.from(contexts).forEach((key, value) async { if (value != null) { await clone.setContexts(key, value); } }); - for (final attachment in _attachments) { + for (final attachment in List.from(_attachments)) { clone.addAttachment(attachment); } From 3d9da60fe7fac6b8f519e8be234f69da3f8f8654 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 19 Jul 2022 13:59:34 +0200 Subject: [PATCH 4/5] await create scope in sentry client test --- dart/test/sentry_client_test.dart | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dart/test/sentry_client_test.dart b/dart/test/sentry_client_test.dart index e676d9122..5e1ab0511 100644 --- a/dart/test/sentry_client_test.dart +++ b/dart/test/sentry_client_test.dart @@ -553,12 +553,12 @@ void main() { breadcrumbs: eventCrumbs, ); - Scope createScope(SentryOptions options) { + Future createScope(SentryOptions options) async { final scope = Scope(options) ..transaction = transaction - ..fingerprint = fingerprint - ..addBreadcrumb(crumb); - scope.setUser(user); + ..fingerprint = fingerprint; + await scope.addBreadcrumb(crumb); + await scope.setUser(user); return scope; } @@ -568,7 +568,7 @@ void main() { test('should not apply the scope to non null event fields ', () async { final client = fixture.getSut(sendDefaultPii: true); - final scope = createScope(fixture.options); + final scope = await createScope(fixture.options); await client.captureEvent(event, scope: scope); @@ -585,7 +585,7 @@ void main() { test('should apply the scope user to null event user fields ', () async { final client = fixture.getSut(sendDefaultPii: true); - final scope = createScope(fixture.options); + final scope = await createScope(fixture.options); await scope.setUser(SentryUser(id: '987')); @@ -608,7 +608,7 @@ void main() { test('merge scope user and event user extra', () async { final client = fixture.getSut(sendDefaultPii: true); - final scope = createScope(fixture.options); + final scope = await createScope(fixture.options); await scope.setUser( SentryUser( From 5b404faa9e056f6d015d0c25502a0cb28dd228b6 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Thu, 21 Jul 2022 08:04:08 +0200 Subject: [PATCH 5/5] fix --- dart/lib/src/scope.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dart/lib/src/scope.dart b/dart/lib/src/scope.dart index b58114194..0802975af 100644 --- a/dart/lib/src/scope.dart +++ b/dart/lib/src/scope.dart @@ -406,11 +406,11 @@ class Scope { clone.addEventProcessor(eventProcessor); } - Map.from(contexts).forEach((key, value) async { - if (value != null) { - await clone.setContexts(key, value); + for (final entry in Map.from(contexts).entries) { + if (entry.value != null) { + await clone.setContexts(entry.key, entry.value); } - }); + } for (final attachment in List.from(_attachments)) { clone.addAttachment(attachment);