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 6fdbb3d6a0..565365ab4d 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 @@ class MockedAppInsightsIngestionServlet extends HttpServlet { 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)); } }