8
8
using System . Globalization ;
9
9
using System . Runtime . Serialization ;
10
10
using System . Text . RegularExpressions ;
11
+ using System . Threading ;
11
12
12
13
namespace System . Net
13
14
{
@@ -127,10 +128,9 @@ public bool UseDefaultCredentials
127
128
128
129
private void UpdateRegexList ( )
129
130
{
130
- Regex [ ] ? regexBypassList = null ;
131
131
if ( _bypassList is ChangeTrackingArrayList bypassList )
132
132
{
133
- bypassList . IsChanged = false ;
133
+ Regex [ ] ? regexBypassList = null ;
134
134
if ( bypassList . Count > 0 )
135
135
{
136
136
regexBypassList = new Regex [ bypassList . Count ] ;
@@ -139,9 +139,14 @@ private void UpdateRegexList()
139
139
regexBypassList [ i ] = new Regex ( ( string ) bypassList [ i ] ! , RegexOptions . IgnoreCase | RegexOptions . CultureInvariant ) ;
140
140
}
141
141
}
142
- }
143
142
144
- _regexBypassList = regexBypassList ;
143
+ _regexBypassList = regexBypassList ;
144
+ bypassList . IsChanged = false ;
145
+ }
146
+ else
147
+ {
148
+ _regexBypassList = null ;
149
+ }
145
150
}
146
151
147
152
private bool IsMatchInBypassList ( Uri input )
@@ -219,7 +224,10 @@ public ChangeTrackingArrayList() { }
219
224
220
225
public ChangeTrackingArrayList ( ICollection c ) : base ( c ) { }
221
226
222
- public bool IsChanged { get ; set ; }
227
+ // While this type isn't intended to be mutated concurrently with reads, non-concurrent updates
228
+ // to the list might result in lazy initialization, and it's possible concurrent HTTP requests could race
229
+ // to trigger that initialization.
230
+ public volatile bool IsChanged ;
223
231
224
232
// Override the methods that can add, remove, or change the regexes in the bypass list.
225
233
// Methods that only read (like CopyTo, BinarySearch, etc.) and methods that reorder
0 commit comments