Skip to content

Commit db94a97

Browse files
authored
Revert unintentional change to EndpointDiscoveryHandler back to what is in the v4-release (#3693)
1 parent 149475e commit db94a97

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

sdk/src/Core/Amazon.Runtime/Pipeline/Handlers/EndpointDiscoveryHandler.cs

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
/*
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+
*/
1515

1616
using System;
1717
using System.Collections.Generic;
@@ -39,14 +39,14 @@ public override void InvokeSync(IExecutionContext executionContext)
3939
var requestContext = executionContext.RequestContext;
4040
var regionalEndpoint = requestContext.Request.Endpoint;
4141
PreInvoke(executionContext);
42-
42+
4343
try
4444
{
4545
base.InvokeSync(executionContext);
4646
return;
4747
}
4848
catch (Exception exception)
49-
{
49+
{
5050
if (IsInvalidEndpointException(exception))
5151
{
5252
EvictCacheKeyForRequest(requestContext, regionalEndpoint);
@@ -69,14 +69,11 @@ public override async System.Threading.Tasks.Task<T> InvokeAsync<T>(IExecutionCo
6969
{
7070
var requestContext = executionContext.RequestContext;
7171
var regionalEndpoint = requestContext.Request.Endpoint;
72+
PreInvoke(executionContext);
7273

73-
var immutableCredentials = (requestContext.Identity as AWSCredentials)?.GetCredentialsAsync();
74-
75-
PreInvoke(executionContext, immutableCredentials);
76-
7774
try
7875
{
79-
return await base.InvokeAsync<T>(executionContext).ConfigureAwait(false);
76+
return await base.InvokeAsync<T>(executionContext).ConfigureAwait(false);
8077
}
8178
catch (Exception exception)
8279
{
@@ -87,7 +84,7 @@ public override async System.Threading.Tasks.Task<T> InvokeAsync<T>(IExecutionCo
8784
}
8885

8986
capturedException.Throw();
90-
}
87+
}
9188

9289
throw new AmazonClientException("Neither a response was returned nor an exception was thrown in the Runtime EndpointDiscoveryResolver.");
9390
}
@@ -100,7 +97,7 @@ public override async System.Threading.Tasks.Task<T> InvokeAsync<T>(IExecutionCo
10097
/// <param name="executionContext">The execution context, it contains the
10198
/// request and response context.</param>
10299
protected static void PreInvoke(IExecutionContext executionContext)
103-
{
100+
{
104101
DiscoverEndpoints(executionContext.RequestContext, false);
105102
}
106103

@@ -110,7 +107,7 @@ public static void EvictCacheKeyForRequest(IRequestContext requestContext, Uri r
110107
requestContext.Request.Endpoint = regionalEndpoint;
111108
}
112109

113-
public static void DiscoverEndpoints(IRequestContext requestContext, bool evictCacheKey, ImmutableCredentials credentials)
110+
public static void DiscoverEndpoints(IRequestContext requestContext, bool evictCacheKey)
114111
{
115112
var discoveryEndpoints = ProcessEndpointDiscovery(requestContext, evictCacheKey, requestContext.Request.Endpoint);
116113
if (discoveryEndpoints != null)
@@ -121,7 +118,7 @@ public static void DiscoverEndpoints(IRequestContext requestContext, bool evictC
121118
//and we couldn't get an endpoint back during an asynchronous discovery
122119
//attempt. The null address endpoint will be evicted after 60 seconds but will
123120
//prevent multiple server requests during this time.
124-
if(endpoint.Address == null)
121+
if (endpoint.Address == null)
125122
{
126123
continue;
127124
}
@@ -133,9 +130,10 @@ public static void DiscoverEndpoints(IRequestContext requestContext, bool evictC
133130
}
134131
}
135132

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+
{
138135
var options = requestContext.Options;
136+
var immutableCredentials = (requestContext.Identity as AWSCredentials)?.GetCredentials();
139137

140138
if (options.EndpointDiscoveryMarshaller != null && options.EndpointOperation != null && immutableCredentials != null)
141139
{
@@ -150,7 +148,7 @@ private static IEnumerable<DiscoveryEndpointBase> ProcessEndpointDiscovery(IRequ
150148
}
151149

152150
return null;
153-
}
151+
}
154152

155153
private static bool IsInvalidEndpointException(Exception exception)
156154
{
@@ -163,4 +161,4 @@ private static bool IsInvalidEndpointException(Exception exception)
163161
return false;
164162
}
165163
}
166-
}
164+
}

0 commit comments

Comments
 (0)