88using System . Globalization ;
99using System . Runtime . Serialization ;
1010using System . Text . RegularExpressions ;
11+ using System . Threading ;
1112
1213namespace System . Net
1314{
@@ -127,10 +128,9 @@ public bool UseDefaultCredentials
127128
128129 private void UpdateRegexList ( )
129130 {
130- Regex [ ] ? regexBypassList = null ;
131131 if ( _bypassList is ChangeTrackingArrayList bypassList )
132132 {
133- bypassList . IsChanged = false ;
133+ Regex [ ] ? regexBypassList = null ;
134134 if ( bypassList . Count > 0 )
135135 {
136136 regexBypassList = new Regex [ bypassList . Count ] ;
@@ -139,9 +139,14 @@ private void UpdateRegexList()
139139 regexBypassList [ i ] = new Regex ( ( string ) bypassList [ i ] ! , RegexOptions . IgnoreCase | RegexOptions . CultureInvariant ) ;
140140 }
141141 }
142- }
143142
144- _regexBypassList = regexBypassList ;
143+ _regexBypassList = regexBypassList ;
144+ bypassList . IsChanged = false ;
145+ }
146+ else
147+ {
148+ _regexBypassList = null ;
149+ }
145150 }
146151
147152 private bool IsMatchInBypassList ( Uri input )
@@ -219,7 +224,10 @@ public ChangeTrackingArrayList() { }
219224
220225 public ChangeTrackingArrayList ( ICollection c ) : base ( c ) { }
221226
222- public bool IsChanged { get ; set ; }
227+ // While this type isn't intended to mutated concurrently with reads, non-concurrent updates
228+ // to the list might result in lazy initialization, and it's possible concurrent requests could race
229+ // to trigger that initialization.
230+ public volatile bool IsChanged ;
223231
224232 // Override the methods that can add, remove, or change the regexes in the bypass list.
225233 // Methods that only read (like CopyTo, BinarySearch, etc.) and methods that reorder
0 commit comments