1
1
/*
2
- * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License").
5
- * You may not use this file except in compliance with the License.
6
- * A copy of the License is located at
7
- *
8
- * http://aws.amazon.com/apache2.0
9
- *
10
- * or in the "license" file accompanying this file. This file is distributed
11
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12
- * express or implied. See the License for the specific language governing
13
- * permissions and limitations under the License.
14
- */
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License").
5
+ * You may not use this file except in compliance with the License.
6
+ * A copy of the License is located at
7
+ *
8
+ * http://aws.amazon.com/apache2.0
9
+ *
10
+ * or in the "license" file accompanying this file. This file is distributed
11
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12
+ * express or implied. See the License for the specific language governing
13
+ * permissions and limitations under the License.
14
+ */
15
15
16
16
using System ;
17
17
using System . Collections . Generic ;
@@ -39,14 +39,14 @@ public override void InvokeSync(IExecutionContext executionContext)
39
39
var requestContext = executionContext . RequestContext ;
40
40
var regionalEndpoint = requestContext . Request . Endpoint ;
41
41
PreInvoke ( executionContext ) ;
42
-
42
+
43
43
try
44
44
{
45
45
base . InvokeSync ( executionContext ) ;
46
46
return ;
47
47
}
48
48
catch ( Exception exception )
49
- {
49
+ {
50
50
if ( IsInvalidEndpointException ( exception ) )
51
51
{
52
52
EvictCacheKeyForRequest ( requestContext , regionalEndpoint ) ;
@@ -69,14 +69,11 @@ public override async System.Threading.Tasks.Task<T> InvokeAsync<T>(IExecutionCo
69
69
{
70
70
var requestContext = executionContext . RequestContext ;
71
71
var regionalEndpoint = requestContext . Request . Endpoint ;
72
+ PreInvoke ( executionContext ) ;
72
73
73
- var immutableCredentials = ( requestContext . Identity as AWSCredentials ) ? . GetCredentialsAsync ( ) ;
74
-
75
- PreInvoke ( executionContext , immutableCredentials ) ;
76
-
77
74
try
78
75
{
79
- return await base . InvokeAsync < T > ( executionContext ) . ConfigureAwait ( false ) ;
76
+ return await base . InvokeAsync < T > ( executionContext ) . ConfigureAwait ( false ) ;
80
77
}
81
78
catch ( Exception exception )
82
79
{
@@ -87,7 +84,7 @@ public override async System.Threading.Tasks.Task<T> InvokeAsync<T>(IExecutionCo
87
84
}
88
85
89
86
capturedException . Throw ( ) ;
90
- }
87
+ }
91
88
92
89
throw new AmazonClientException ( "Neither a response was returned nor an exception was thrown in the Runtime EndpointDiscoveryResolver." ) ;
93
90
}
@@ -100,7 +97,7 @@ public override async System.Threading.Tasks.Task<T> InvokeAsync<T>(IExecutionCo
100
97
/// <param name="executionContext">The execution context, it contains the
101
98
/// request and response context.</param>
102
99
protected static void PreInvoke ( IExecutionContext executionContext )
103
- {
100
+ {
104
101
DiscoverEndpoints ( executionContext . RequestContext , false ) ;
105
102
}
106
103
@@ -110,7 +107,7 @@ public static void EvictCacheKeyForRequest(IRequestContext requestContext, Uri r
110
107
requestContext . Request . Endpoint = regionalEndpoint ;
111
108
}
112
109
113
- public static void DiscoverEndpoints ( IRequestContext requestContext , bool evictCacheKey , ImmutableCredentials credentials )
110
+ public static void DiscoverEndpoints ( IRequestContext requestContext , bool evictCacheKey )
114
111
{
115
112
var discoveryEndpoints = ProcessEndpointDiscovery ( requestContext , evictCacheKey , requestContext . Request . Endpoint ) ;
116
113
if ( discoveryEndpoints != null )
@@ -121,7 +118,7 @@ public static void DiscoverEndpoints(IRequestContext requestContext, bool evictC
121
118
//and we couldn't get an endpoint back during an asynchronous discovery
122
119
//attempt. The null address endpoint will be evicted after 60 seconds but will
123
120
//prevent multiple server requests during this time.
124
- if ( endpoint . Address == null )
121
+ if ( endpoint . Address == null )
125
122
{
126
123
continue ;
127
124
}
@@ -133,9 +130,10 @@ public static void DiscoverEndpoints(IRequestContext requestContext, bool evictC
133
130
}
134
131
}
135
132
136
- private static IEnumerable < DiscoveryEndpointBase > ProcessEndpointDiscovery ( IRequestContext requestContext , bool evictCacheKey , Uri evictUri , ImmutableCredentials immutableCredentials )
137
- {
133
+ private static IEnumerable < DiscoveryEndpointBase > ProcessEndpointDiscovery ( IRequestContext requestContext , bool evictCacheKey , Uri evictUri )
134
+ {
138
135
var options = requestContext . Options ;
136
+ var immutableCredentials = ( requestContext . Identity as AWSCredentials ) ? . GetCredentials ( ) ;
139
137
140
138
if ( options . EndpointDiscoveryMarshaller != null && options . EndpointOperation != null && immutableCredentials != null )
141
139
{
@@ -150,7 +148,7 @@ private static IEnumerable<DiscoveryEndpointBase> ProcessEndpointDiscovery(IRequ
150
148
}
151
149
152
150
return null ;
153
- }
151
+ }
154
152
155
153
private static bool IsInvalidEndpointException ( Exception exception )
156
154
{
@@ -163,4 +161,4 @@ private static bool IsInvalidEndpointException(Exception exception)
163
161
return false ;
164
162
}
165
163
}
166
- }
164
+ }
0 commit comments