3838@ SuppressWarnings ("deprecation" )
3939public class DefaultAcsClient implements IAcsClient {
4040
41- /*
42- Now maxRetryNumber and autoRetry has no effect.
43- */
41+ // Now maxRetryNumber and autoRetry has no effect.
4442 private int maxRetryNumber = 3 ;
4543 private boolean autoRetry = true ;
46- private IClientProfile clientProfile = null ;
44+ private IClientProfile clientProfile ;
4745 private AlibabaCloudCredentialsProvider credentialsProvider ;
4846
4947 private IHttpClient httpClient ;
@@ -118,12 +116,10 @@ public <T extends AcsResponse> HttpResponse doAction(AcsRequest<T> request, Stri
118116 request .setSysSignatureAlgorithm (this .signatureAlgorithm );
119117 }
120118 Signer signer = Signer .getSigner (new LegacyCredentials (credential ), request .getSysSignatureVersion (), request .getSysSignatureAlgorithm ());
121- FormatType format = null ;
122119 if (null == request .getSysRegionId ()) {
123120 request .setSysRegionId (regionId );
124121 }
125- return doAction (request , autoRetry , maxRetryNumber , regionId , new LegacyCredentials (credential ), signer ,
126- format );
122+ return doAction (request , regionId , new LegacyCredentials (credential ), signer , null );
127123 }
128124
129125 @ Override
@@ -191,8 +187,6 @@ public <T extends AcsResponse> HttpResponse doAction(AcsRequest<T> request, bool
191187 if (null == profile ) {
192188 throw new ClientException ("SDK.InvalidProfile" , "No active profile found." );
193189 }
194- boolean retry = autoRetry ;
195- int retryNumber = maxRetryCounts ;
196190 String region = profile .getRegionId ();
197191 if (null == request .getSysRegionId ()) {
198192 request .setSysRegionId (region );
@@ -212,7 +206,7 @@ public <T extends AcsResponse> HttpResponse doAction(AcsRequest<T> request, bool
212206 Signer signer = Signer .getSigner (credentials , request .getSysSignatureVersion (), request .getSysSignatureAlgorithm ());
213207 FormatType format = profile .getFormat ();
214208
215- return this .doAction (request , retry , retryNumber , request .getSysRegionId (), credentials , signer , format );
209+ return this .doAction (request , request .getSysRegionId (), credentials , signer , format );
216210 }
217211
218212 private <T extends AcsResponse > T parseAcsResponse (AcsRequest <T > request , HttpResponse baseResponse )
@@ -254,13 +248,13 @@ private <T extends AcsResponse> T parseAcsResponse(AcsRequest<T> request, HttpRe
254248 public <T extends AcsResponse > HttpResponse doAction (AcsRequest <T > request , boolean autoRetry , int maxRetryNumber ,
255249 String regionId , Credential credential , Signer signer , FormatType format )
256250 throws ClientException , ServerException {
257- return doAction (request , autoRetry , maxRetryNumber , regionId , new LegacyCredentials (credential ), signer ,
251+ return doAction (request , regionId , new LegacyCredentials (credential ), signer ,
258252 format );
259253 }
260254
261255 public ProductDomain getDomain (AcsRequest request , String regionId )
262256 throws ClientException {
263- ProductDomain domain = null ;
257+ ProductDomain domain ;
264258 if (request .getSysProductDomain () != null ) {
265259 domain = request .getSysProductDomain ();
266260 } else {
@@ -283,11 +277,11 @@ public ProductDomain getDomain(AcsRequest request, String regionId)
283277 return domain ;
284278 }
285279
286- private <T extends AcsResponse > HttpResponse doAction (AcsRequest <T > request , boolean autoRetry , int maxRetryNumber ,
280+ private <T extends AcsResponse > HttpResponse doAction (AcsRequest <T > request ,
287281 String regionId , AlibabaCloudCredentials credentials , Signer signer , FormatType format )
288282 throws ClientException , ServerException {
289283 if (!GlobalTracer .isRegistered () || clientProfile .isCloseTrace ()) {
290- return doRealAction (request , autoRetry , maxRetryNumber , regionId , credentials , signer , format );
284+ return doRealAction (request , regionId , credentials , signer , format );
291285 }
292286
293287 Tracer tracer = GlobalTracer .get ();
@@ -302,7 +296,7 @@ private <T extends AcsResponse> HttpResponse doAction(AcsRequest<T> request, boo
302296 .start ();
303297 tracer .inject (span .context (), Format .Builtin .HTTP_HEADERS , new HttpHeadersInjectAdapter (request ));
304298 try {
305- HttpResponse response = doRealAction (request , autoRetry , maxRetryNumber , regionId , credentials , signer , format );
299+ HttpResponse response = doRealAction (request , regionId , credentials , signer , format );
306300 span .setTag ("status" , response .getStatus ());
307301 span .setTag ("ReasonPhrase" , response .getReasonPhrase ());
308302 return response ;
@@ -315,7 +309,7 @@ private <T extends AcsResponse> HttpResponse doAction(AcsRequest<T> request, boo
315309
316310 }
317311
318- private <T extends AcsResponse > HttpResponse doRealAction (AcsRequest <T > request , boolean autoRetry , int maxRetryNumber ,
312+ private <T extends AcsResponse > HttpResponse doRealAction (AcsRequest <T > request ,
319313 String regionId , AlibabaCloudCredentials credentials , Signer signer , FormatType format )
320314 throws ClientException , ServerException {
321315
@@ -454,17 +448,17 @@ private <T extends AcsResponse> HttpResponse doRealAction(AcsRequest<T> request,
454448 * 2019-01-03 change access control from private to protected, then subClass can
455449 * override it and rewrite httpResponse processing
456450 */
457- protected <T extends AcsResponse > T readResponse (Class <T > clasz , HttpResponse httpResponse , FormatType format )
451+ protected <T extends AcsResponse > T readResponse (Class <T > clazz , HttpResponse httpResponse , FormatType format )
458452 throws ClientException {
459453 // new version response contains "@XmlRootElement" annotation
460- if (clasz .isAnnotationPresent (XmlRootElement .class )
454+ if (clazz .isAnnotationPresent (XmlRootElement .class )
461455 && !clientProfile .getHttpClientConfig ().isCompatibleMode ()) {
462456 Unmarshaller unmarshaller = UnmarshallerFactory .getUnmarshaller (format );
463- return unmarshaller .unmarshal (clasz , httpResponse .getHttpContentString ());
457+ return unmarshaller .unmarshal (clazz , httpResponse .getHttpContentString ());
464458 } else {
465459 Reader reader = ReaderFactory .createInstance (format );
466460 UnmarshallerContext context = new UnmarshallerContext ();
467- T response = null ;
461+ T response ;
468462 String stringContent = httpResponse .getHttpContentString ();
469463
470464 if (stringContent == null ) {
@@ -473,13 +467,13 @@ protected <T extends AcsResponse> T readResponse(Class<T> clasz, HttpResponse ht
473467 }
474468
475469 try {
476- response = clasz .newInstance ();
470+ response = clazz .newInstance ();
477471 } catch (Exception e ) {
478472 throw new ClientException ("SDK.InvalidResponseClass" ,
479- "Unable to allocate " + clasz .getName () + " class" );
473+ "Unable to allocate " + clazz .getName () + " class" );
480474 }
481475
482- String responseEndpoint = clasz .getName ().substring (clasz .getName ().lastIndexOf ("." ) + 1 );
476+ String responseEndpoint = clazz .getName ().substring (clazz .getName ().lastIndexOf ("." ) + 1 );
483477 if (response .checkShowJsonItemName ()) {
484478 context .setResponseMap (reader .read (stringContent , responseEndpoint ));
485479 } else {
@@ -532,6 +526,7 @@ public void doActionWithProxy(ProtocolType protocolType, String httpsProxy, Stri
532526 config .setHttpsProxy (httpsProxy );
533527 return ;
534528 }
529+ return ;
535530 }
536531
537532 /**
0 commit comments