From 1a4531e4b79434ea200c34f386519e0c0e686a14 Mon Sep 17 00:00:00 2001 From: JXC486 Date: Fri, 24 Feb 2023 15:37:39 -0700 Subject: [PATCH] 263 Fix concurrency issue in the Journey class by synchronizing the ArrayList --- .../moskito/core/journey/Journey.java | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/moskito-core/src/main/java/net/anotheria/moskito/core/journey/Journey.java b/moskito-core/src/main/java/net/anotheria/moskito/core/journey/Journey.java index a8153a245..18abfcbb9 100644 --- a/moskito-core/src/main/java/net/anotheria/moskito/core/journey/Journey.java +++ b/moskito-core/src/main/java/net/anotheria/moskito/core/journey/Journey.java @@ -3,6 +3,7 @@ import net.anotheria.moskito.core.calltrace.CurrentlyTracedCall; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -43,7 +44,7 @@ public Journey(String aName){ name = aName; createdTimestamp = System.currentTimeMillis(); active = true; - tracedCalls = new ArrayList<>(); + tracedCalls = Collections.synchronizedList(new ArrayList<>()); } /** @@ -94,23 +95,27 @@ public String toString(){ } public void removeStepByName(String stepName){ - for (int i=0; i