From 7c56e5307658eca580aee4540f28a41b9f8a011f Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Fri, 2 Aug 2024 09:38:41 -0700 Subject: [PATCH] Fix sporadic test failure --- .../fakeingestion/MockedAppInsightsIngestionServlet.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/smoke-tests/framework/src/main/java/com/microsoft/applicationinsights/smoketest/fakeingestion/MockedAppInsightsIngestionServlet.java b/smoke-tests/framework/src/main/java/com/microsoft/applicationinsights/smoketest/fakeingestion/MockedAppInsightsIngestionServlet.java index 6fdbb3d6a0b..565365ab4d9 100644 --- a/smoke-tests/framework/src/main/java/com/microsoft/applicationinsights/smoketest/fakeingestion/MockedAppInsightsIngestionServlet.java +++ b/smoke-tests/framework/src/main/java/com/microsoft/applicationinsights/smoketest/fakeingestion/MockedAppInsightsIngestionServlet.java @@ -65,7 +65,9 @@ int getItemCount() { List getItemsByType(String type) { Objects.requireNonNull(type, "type"); synchronized (multimapLock) { - return type2envelope.get(type); + // need to make a copy to avoid ConcurrentModificationException + // if the caller iterates over it at the same time as another telemetry item arrives + return new ArrayList<>(type2envelope.get(type)); } }