Skip to content

Commit 0e77499

Browse files
committed
fix error compiling
1 parent 38149f1 commit 0e77499

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/Microsoft.Extensions.Configuration.AzureAppConfiguration/AzureAppConfigurationOptions.cs

+9-13
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using System.Collections.Generic;
1313
using System.Linq;
1414
using System.Net.Http;
15+
using System.Threading;
1516
using System.Threading.Tasks;
1617

1718
namespace Microsoft.Extensions.Configuration.AzureAppConfiguration
@@ -34,6 +35,10 @@ public class AzureAppConfigurationOptions : IDisposable
3435
private List<KeyValueSelector> _selectors;
3536
private IConfigurationRefresher _refresher = new AzureAppConfigurationRefresher();
3637
private bool _selectCalled = false;
38+
private static HttpClientTransport _clientOptionsTransport = new HttpClientTransport(new HttpClient()
39+
{
40+
Timeout = NetworkTimeout
41+
});
3742

3843
// The following set is sorted in descending order.
3944
// Since multiple prefixes could start with the same characters, we need to trim the longest prefix first.
@@ -150,11 +155,6 @@ internal IEnumerable<IKeyValueAdapter> Adapters
150155
/// </summary>
151156
internal StartupOptions Startup { get; set; } = new StartupOptions();
152157

153-
/// <summary>
154-
/// Transport used by <see cref="ClientOptions"/>, stored for disposal.
155-
/// </summary>
156-
internal HttpClientTransport ClientOptionsTransport { get; private set; } = null;
157-
158158
/// <summary>
159159
/// Initializes a new instance of the <see cref="AzureAppConfigurationOptions"/> class.
160160
/// </summary>
@@ -511,18 +511,14 @@ public AzureAppConfigurationOptions ConfigureStartupOptions(Action<StartupOption
511511
return this;
512512
}
513513

514-
private ConfigurationClientOptions GetDefaultClientOptions()
514+
private static ConfigurationClientOptions GetDefaultClientOptions()
515515
{
516516
var clientOptions = new ConfigurationClientOptions(ConfigurationClientOptions.ServiceVersion.V2023_10_01);
517517
clientOptions.Retry.MaxRetries = MaxRetries;
518518
clientOptions.Retry.MaxDelay = MaxRetryDelay;
519519
clientOptions.Retry.Mode = RetryMode.Exponential;
520520
clientOptions.AddPolicy(new UserAgentHeaderPolicy(), HttpPipelinePosition.PerCall);
521-
ClientOptionsTransport = new HttpClientTransport(new HttpClient()
522-
{
523-
Timeout = NetworkTimeout
524-
});
525-
clientOptions.Transport = ClientOptionsTransport;
521+
clientOptions.Transport = _clientOptionsTransport;
526522

527523
return clientOptions;
528524
}
@@ -532,9 +528,9 @@ private ConfigurationClientOptions GetDefaultClientOptions()
532528
/// </summary>
533529
public void Dispose()
534530
{
535-
if (ClientOptionsTransport != null)
531+
if (_clientOptionsTransport != null)
536532
{
537-
ClientOptionsTransport.Dispose();
533+
_clientOptionsTransport.Dispose();
538534
}
539535
}
540536
}

0 commit comments

Comments
 (0)