From 2fc073f9ca3d36e8c3cd086773719dc5f8274c36 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Wed, 19 Jun 2024 00:45:36 -0400 Subject: [PATCH] Fix locking in ReflectionComposablePart.ImportsCache (#103660) The second check needs to use the value from the field (to see updates made by other threads), not the local variable. Fixes: #103650 --- .../Composition/ReflectionModel/ReflectionComposablePart.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionComposablePart.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionComposablePart.cs index c8a7054c5966c..609511bb33bff 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionComposablePart.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionComposablePart.cs @@ -87,6 +87,7 @@ private Dictionary ImportsCache { lock (_lock) { + value = _importsCache; if (value == null) { value = new Dictionary();