protected void logResponse(ComponentLog logger, GenericApiGatewayResponse response) { try { logger.debug("\nResponse from remote service:\n\t{}\n{}", new Object[]{response.getHttpResponse().getHttpRequest().getURI().toURL().toExternalForm(), getLogString(response.getHttpResponse().getHeaders())}); } catch (MalformedURLException e) { logger.debug(e.getMessage()); } }
/** * Determine if an interrupted exception is caused by the client execution timer * interrupting the current thread or some other task interrupting the thread for another * purpose. * * @return {@link ClientExecutionTimeoutException} if the {@link InterruptedException} was * caused by the {@link ClientExecutionTimer}. Otherwise re-interrupts the current thread * and returns a {@link SdkClientException} wrapping an {@link InterruptedException} */ private RuntimeException handleInterruptedException(InterruptedException e) { if (e instanceof SdkInterruptedException) { if (((SdkInterruptedException) e).getResponse() != null) { ((SdkInterruptedException) e).getResponse().getHttpResponse().getHttpRequest().abort(); } } if (executionContext.getClientExecutionTrackerTask().hasTimeoutExpired()) { // Clear the interrupt status Thread.interrupted(); ClientExecutionTimeoutException exception = new ClientExecutionTimeoutException(); reportClientExecutionTimeout(exception); return exception; } else { Thread.currentThread().interrupt(); return new AbortedException(e); } }
/** * @see com.amazonaws.http.HttpResponseHandler#handle(com.amazonaws.http.HttpResponse) */ public AmazonWebServiceResponse<S3Object> handle(HttpResponse response) throws Exception { /* * TODO: It'd be nice to set the bucket name and key here, but the information isn't easy to * pull out of the response/request currently. */ S3Object object = new S3Object(); AmazonWebServiceResponse<S3Object> awsResponse = parseResponseMetadata(response); if (response.getHeaders().get(Headers.REDIRECT_LOCATION) != null) { object.setRedirectLocation(response.getHeaders().get(Headers.REDIRECT_LOCATION)); } // If the requester is charged when downloading a object from an // Requester Pays bucket, then this header is set. if (response.getHeaders().get(Headers.REQUESTER_CHARGED_HEADER) != null) { object.setRequesterCharged(true); } if (response.getHeaders().get(Headers.S3_TAGGING_COUNT) != null) { object.setTaggingCount(Integer.parseInt(response.getHeaders().get(Headers.S3_TAGGING_COUNT))); } ObjectMetadata metadata = object.getObjectMetadata(); populateObjectMetadata(response, metadata); object.setObjectContent(new S3ObjectInputStream(response.getContent(), response.getHttpRequest())); awsResponse.setResult(object); return awsResponse; }
/** * Determine if an interrupted exception is caused by the client execution timer * interrupting the current thread or some other task interrupting the thread for another * purpose. * * @return {@link ClientExecutionTimeoutException} if the {@link InterruptedException} was * caused by the {@link ClientExecutionTimer}. Otherwise re-interrupts the current thread * and returns a {@link SdkClientException} wrapping an {@link InterruptedException} */ private RuntimeException handleInterruptedException(InterruptedException e) { if (e instanceof SdkInterruptedException) { if (((SdkInterruptedException) e).getResponse() != null) { ((SdkInterruptedException) e).getResponse().getHttpResponse().getHttpRequest().abort(); } } if (executionContext.getClientExecutionTrackerTask().hasTimeoutExpired()) { // Clear the interrupt status Thread.interrupted(); ClientExecutionTimeoutException exception = new ClientExecutionTimeoutException(); reportClientExecutionTimeout(exception); return exception; } else { Thread.currentThread().interrupt(); return new AbortedException(e); } }
private S3AbortableInputStream abortableIs(HttpResponse response) { return new S3AbortableInputStream(response.getContent(), response.getHttpRequest(), getContentLength(response)); }
protected void logResponse(ComponentLog logger, GenericApiGatewayResponse response) { try { logger.debug("\nResponse from remote service:\n\t{}\n{}", new Object[]{response.getHttpResponse().getHttpRequest().getURI().toURL().toExternalForm(), getLogString(response.getHttpResponse().getHeaders())}); } catch (MalformedURLException e) { logger.debug(e.getMessage()); } }
/** * Determine if an interrupted exception is caused by the client execution timer * interrupting the current thread or some other task interrupting the thread for another * purpose. * * @return {@link ClientExecutionTimeoutException} if the {@link InterruptedException} was * caused by the {@link ClientExecutionTimer}. Otherwise re-interrupts the current thread * and returns a {@link SdkClientException} wrapping an {@link InterruptedException} */ private RuntimeException handleInterruptedException(InterruptedException e) { if (e instanceof SdkInterruptedException) { if (((SdkInterruptedException) e).getResponse() != null) { ((SdkInterruptedException) e).getResponse().getHttpResponse().getHttpRequest().abort(); } } if (executionContext.getClientExecutionTrackerTask().hasTimeoutExpired()) { // Clear the interrupt status Thread.interrupted(); return new ClientExecutionTimeoutException(); } else { Thread.currentThread().interrupt(); return new AbortedException(e); } }
/** * @see com.amazonaws.http.HttpResponseHandler#handle(com.amazonaws.http.HttpResponse) */ public AmazonWebServiceResponse<S3Object> handle(HttpResponse response) throws Exception { /* * TODO: It'd be nice to set the bucket name and key here, but the information isn't easy to * pull out of the response/request currently. */ S3Object object = new S3Object(); AmazonWebServiceResponse<S3Object> awsResponse = parseResponseMetadata(response); if (response.getHeaders().get(Headers.REDIRECT_LOCATION) != null) { object.setRedirectLocation(response.getHeaders().get(Headers.REDIRECT_LOCATION)); } // If the requester is charged when downloading a object from an // Requester Pays bucket, then this header is set. if (response.getHeaders().get(Headers.REQUESTER_CHARGED_HEADER) != null) { object.setRequesterCharged(true); } if (response.getHeaders().get(Headers.S3_TAGGING_COUNT) != null) { object.setTaggingCount(Integer.parseInt(response.getHeaders().get(Headers.S3_TAGGING_COUNT))); } ObjectMetadata metadata = object.getObjectMetadata(); populateObjectMetadata(response, metadata); object.setObjectContent(new S3ObjectInputStream(abortableIs(response), response.getHttpRequest())); awsResponse.setResult(object); return awsResponse; }