@@ -96,7 +96,7 @@ private Task<HttpResponseMessage> DoPostPutAsync<T>(HttpMethod method, string ur
9696 // as it is disposed after each call
9797 var origin = GetOriginFromUri ( uri ) ;
9898
99- return HttpInvoker ( origin , ( ) =>
99+ return HttpInvoker ( origin , async ( ) =>
100100 {
101101 var requestMessage = new HttpRequestMessage ( method , uri ) ;
102102
@@ -112,7 +112,7 @@ private Task<HttpResponseMessage> DoPostPutAsync<T>(HttpMethod method, string ur
112112 requestMessage . Headers . Add ( "x-requestid" , requestId ) ;
113113 }
114114
115- var response = _client . SendAsync ( requestMessage ) . Result ;
115+ var response = await _client . SendAsync ( requestMessage ) ;
116116
117117 // raise exception if HttpResponseCode 500
118118 // needed for circuit breaker to track fails
@@ -122,7 +122,7 @@ private Task<HttpResponseMessage> DoPostPutAsync<T>(HttpMethod method, string ur
122122 throw new HttpRequestException ( ) ;
123123 }
124124
125- return Task . FromResult ( response ) ;
125+ return response ;
126126 } ) ;
127127 }
128128
@@ -132,13 +132,13 @@ private async Task<T> HttpInvoker<T>(string origin, Func<Task<T>> action)
132132
133133 if ( ! _policyWrappers . TryGetValue ( normalizedOrigin , out PolicyWrap policyWrap ) )
134134 {
135- policyWrap = Policy . Wrap ( _policyCreator ( normalizedOrigin ) . ToArray ( ) ) ;
135+ policyWrap = Policy . WrapAsync ( _policyCreator ( normalizedOrigin ) . ToArray ( ) ) ;
136136 _policyWrappers . TryAdd ( normalizedOrigin , policyWrap ) ;
137137 }
138138
139139 // Executes the action applying all
140140 // the policies defined in the wrapper
141- return await policyWrap . Execute ( action , new Context ( normalizedOrigin ) ) ;
141+ return await policyWrap . ExecuteAsync ( action , new Context ( normalizedOrigin ) ) ;
142142 }
143143
144144
0 commit comments