From c3af4b5c4e8ac03c7072d8da083c1ecbafe4ed39 Mon Sep 17 00:00:00 2001 From: Scott Beddall Date: Sun, 28 Jul 2024 19:34:16 -0700 Subject: [PATCH] more effective lock utilization --- .../Common/RecordSession.cs | 10 ++++++++++ .../Azure.Sdk.Tools.TestProxy/RecordingHandler.cs | 12 ++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/RecordSession.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/RecordSession.cs index a0414ef9441..8cd39ca831b 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/RecordSession.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Common/RecordSession.cs @@ -118,5 +118,15 @@ public void Sanitize(RecordedTestSanitizer sanitizer) sanitizer.Sanitize(this); } } + public void Sanitize(IEnumerable sanitizers) + { + lock (Entries) + { + foreach(var sanitizer in sanitizers) + { + sanitizer.Sanitize(this); + } + } + } } } diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs index 7690acf82cf..04e6f55bfb7 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs @@ -114,11 +114,7 @@ public void StopRecording(string sessionId, IDictionary variable } var sanitizers = SanitizerRegistry.GetSanitizers(recordingSession); - - foreach (RecordedTestSanitizer sanitizer in sanitizers) - { - recordingSession.Session.Sanitize(sanitizer); - } + recordingSession.Session.Sanitize(sanitizers); if (variables != null) { @@ -464,11 +460,7 @@ public async Task HandlePlaybackRequest(string recordingId, HttpRequest incoming { if (!session.IsSanitized) { - foreach (RecordedTestSanitizer sanitizer in sanitizers) - { - session.Session.Sanitize(sanitizer); - } - + session.Session.Sanitize(sanitizers); session.IsSanitized = true; } }