Skip to content

Commit

Permalink
Fix concurrent modification when creating TrackerEvent by copying the…
Browse files Browse the repository at this point in the history
… payload (close #692)

PR #696
  • Loading branch information
matus-tomlein authored Aug 22, 2024
1 parent fa694a5 commit 5376f11
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ class TrackerEvent @JvmOverloads constructor(event: Event, state: TrackerStateSn
init {
entities = event.entities.toMutableList()
trueTimestamp = event.trueTimestamp
payload = HashMap(event.dataPayload)

// NOTE: this code is a workaround since the types of the `Event.dataPayload` and `TrackerEvent.payload` don't match
// `Event` allows the values to be optional, while `TrackerEvent` does not.
// We should fix this in the next major version to unify the types.
// The `toMap()` is called in order to make a copy before calling HashMap as that can lead to concurrency issues, see #692
payload = HashMap(event.dataPayload.toMap())

if (state != null) {
this.state = state
} else {
Expand Down

0 comments on commit 5376f11

Please sign in to comment.