コード例 #1
0
ファイル: AWSUtils.java プロジェクト: GERey/jclouds
 public AWSError parseAWSErrorFromContent(HttpRequest request, HttpResponse response) {
   if (response.getPayload() == null) return null;
   if ("text/plain".equals(response.getPayload().getContentMetadata().getContentType()))
     return null;
   try {
     AWSError error =
         factory.create(errorHandlerProvider.get()).setContext(request).apply(response);
     if (error.getRequestId() == null)
       error.setRequestId(response.getFirstHeaderOrNull(requestId));
     error.setRequestToken(response.getFirstHeaderOrNull(requestToken));
     if ("SignatureDoesNotMatch".equals(error.getCode())) {
       error.setStringSigned(signer.createStringToSign(request));
       error.setSignature(signer.sign(error.getStringSigned()));
     }
     return error;
   } catch (RuntimeException e) {
     logger.warn(e, "error parsing error");
     return null;
   }
 }
コード例 #2
0
 protected boolean shouldRetryRequestOnError(
     HttpCommand command, HttpResponse response, AWSError error) {
   if (retryableServerCodes.contains(error.getCode()))
     return super.shouldRetryRequest(command, response);
   return false;
 }