1212using  System . Collections . Generic ; 
1313using  System . Linq ; 
1414using  System . Net . Http ; 
15+ using  System . Threading ; 
1516using  System . Threading . Tasks ; 
1617
1718namespace  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  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. 
@@ -128,7 +133,7 @@ internal IEnumerable<IKeyValueAdapter> Adapters
128133        /// <summary> 
129134        /// Options used to configure the client used to communicate with Azure App Configuration. 
130135        /// </summary> 
131-         internal  ConfigurationClientOptions  ClientOptions  {  get ;  }   =   GetDefaultClientOptions ( ) ; 
136+         internal  ConfigurationClientOptions  ClientOptions  {  get ;  } 
132137
133138        /// <summary> 
134139        /// Flag to indicate whether Key Vault options have been configured. 
@@ -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> 
@@ -169,6 +169,8 @@ public AzureAppConfigurationOptions()
169169
170170            // Adds the default query to App Configuration if <see cref="Select"/> and <see cref="SelectSnapshot"/> are never called. 
171171            _selectors  =  new  List < KeyValueSelector >  {  DefaultQuery  } ; 
172+ 
173+             ClientOptions  =  GetDefaultClientOptions ( ) ; 
172174        } 
173175
174176        /// <summary> 
@@ -518,11 +520,7 @@ private ConfigurationClientOptions GetDefaultClientOptions()
518520            clientOptions . Retry . MaxDelay  =  MaxRetryDelay ; 
519521            clientOptions . Retry . Mode  =  RetryMode . Exponential ; 
520522            clientOptions . AddPolicy ( new  UserAgentHeaderPolicy ( ) ,  HttpPipelinePosition . PerCall ) ; 
521-             ClientOptionsTransport  =  new  HttpClientTransport ( new  HttpClient ( ) 
522-             { 
523-                 Timeout  =  NetworkTimeout 
524-             } ) ; 
525-             clientOptions . Transport  =  ClientOptionsTransport ; 
523+             clientOptions . Transport  =  _clientOptionsTransport ; 
526524
527525            return  clientOptions ; 
528526        } 
@@ -532,9 +530,9 @@ private ConfigurationClientOptions GetDefaultClientOptions()
532530        /// </summary> 
533531        public  void  Dispose ( ) 
534532        { 
535-             if  ( ClientOptionsTransport  !=  null ) 
533+             if  ( _clientOptionsTransport  !=  null ) 
536534            { 
537-                 ClientOptionsTransport . Dispose ( ) ; 
535+                 _clientOptionsTransport . Dispose ( ) ; 
538536            } 
539537        } 
540538    } 
0 commit comments