/** * @return True if the {@link HttpEntity} should be wrapped in a {@link BufferedHttpEntity} */ private boolean shouldBufferHttpEntity(final boolean needsConnectionLeftOpen, final ExecutionContext execContext, ExecOneRequestParams execParams, final HttpRequestAbortTaskTracker requestAbortTaskTracker) { return (execContext.getClientExecutionTrackerTask().isEnabled() || requestAbortTaskTracker.isEnabled()) && !needsConnectionLeftOpen && execParams.apacheResponse.getEntity() != null; }
/** * Determine if an aborted exception is caused by the client execution timer interrupting * the current thread. If so throws {@link ClientExecutionTimeoutException} else throws the * original {@link AbortedException} * * @param ae aborted exception that occurred * @return {@link ClientExecutionTimeoutException} if the {@link AbortedException} was * caused by the {@link ClientExecutionTimer}. Otherwise throws the original {@link * AbortedException} */ private RuntimeException handleAbortedException(final AbortedException ae) { if (executionContext.getClientExecutionTrackerTask().hasTimeoutExpired()) { // Clear the interrupt status Thread.interrupted(); ClientExecutionTimeoutException exception = new ClientExecutionTimeoutException(); reportClientExecutionTimeout(exception); return exception; } else { Thread.currentThread().interrupt(); return ae; } }
/** * Start and end client execution timer around the execution of the request. It's important * that the client execution task is canceled before the InterruptedExecption is handled by * {@link #execute()} so * the interrupt status doesn't leak out to the callers code */ private Response<Output> executeWithTimer() throws InterruptedException { ClientExecutionAbortTrackerTask clientExecutionTrackerTask = clientExecutionTimer.startTimer(getClientExecutionTimeout(requestConfig)); try { executionContext.setClientExecutionTrackerTask(clientExecutionTrackerTask); return doExecute(); } finally { executionContext.getClientExecutionTrackerTask().cancelTask(); } }
/** * 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); } }
executionContext.getClientExecutionTrackerTask().setCurrentHttpRequest(execOneParams.apacheRequest); final HttpRequestAbortTaskTracker requestAbortTaskTracker = httpRequestTimer .startTimer(execOneParams.apacheRequest, getRequestTimeout(requestConfig)); if (executionContext.getClientExecutionTrackerTask().hasTimeoutExpired()) { throw new InterruptedException(); } else if (requestAbortTaskTracker.httpRequestAborted()) {
/** * @return True if the {@link HttpEntity} should be wrapped in a {@link BufferedHttpEntity} */ private boolean shouldBufferHttpEntity(final boolean needsConnectionLeftOpen, final ExecutionContext execContext, ExecOneRequestParams execParams, final HttpRequestAbortTaskTracker requestAbortTaskTracker) { return (execContext.getClientExecutionTrackerTask().isEnabled() || requestAbortTaskTracker.isEnabled()) && !needsConnectionLeftOpen && execParams.apacheResponse.getEntity() != null; }
/** * Determine if an aborted exception is caused by the client execution timer interrupting * the current thread. If so throws {@link ClientExecutionTimeoutException} else throws the * original {@link AbortedException} * * @param ae aborted exception that occurred * @return {@link ClientExecutionTimeoutException} if the {@link AbortedException} was * caused by the {@link ClientExecutionTimer}. Otherwise throws the original {@link * AbortedException} */ private RuntimeException handleAbortedException(final AbortedException ae) { if (executionContext.getClientExecutionTrackerTask().hasTimeoutExpired()) { // Clear the interrupt status Thread.interrupted(); ClientExecutionTimeoutException exception = new ClientExecutionTimeoutException(); reportClientExecutionTimeout(exception); return exception; } else { Thread.currentThread().interrupt(); return ae; } }
/** * Start and end client execution timer around the execution of the request. It's important * that the client execution task is canceled before the InterruptedExecption is handled by * {@link #execute()} so * the interrupt status doesn't leak out to the callers code */ private Response<Output> executeWithTimer() throws InterruptedException { ClientExecutionAbortTrackerTask clientExecutionTrackerTask = clientExecutionTimer.startTimer(getClientExecutionTimeout(requestConfig)); try { executionContext.setClientExecutionTrackerTask(clientExecutionTrackerTask); return doExecute(); } finally { executionContext.getClientExecutionTrackerTask().cancelTask(); } }
/** * 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); } }
executionContext.getClientExecutionTrackerTask().setCurrentHttpRequest(execOneParams.apacheRequest); final HttpRequestAbortTaskTracker requestAbortTaskTracker = httpRequestTimer .startTimer(execOneParams.apacheRequest, getRequestTimeout(requestConfig)); if (executionContext.getClientExecutionTrackerTask().hasTimeoutExpired()) { throw new InterruptedException(); } else if (requestAbortTaskTracker.httpRequestAborted()) {
/** * @return True if the {@link HttpEntity} should be wrapped in a {@link BufferedHttpEntity} */ private boolean shouldBufferHttpEntity(final boolean needsConnectionLeftOpen, final ExecutionContext execContext, ExecOneRequestParams execParams, final HttpRequestAbortTaskTracker requestAbortTaskTracker) { return (execContext.getClientExecutionTrackerTask().isEnabled() || requestAbortTaskTracker.isEnabled()) && !needsConnectionLeftOpen && execParams.apacheResponse.getEntity() != null; }
/** * Determine if an aborted exception is caused by the client execution timer interrupting * the current thread. If so throws {@link ClientExecutionTimeoutException} else throws the * original {@link AbortedException} * * @param ae aborted exception that occurred * @return {@link ClientExecutionTimeoutException} if the {@link AbortedException} was * caused by the {@link ClientExecutionTimer}. Otherwise throws the original {@link * AbortedException} */ private RuntimeException handleAbortedException(final AbortedException ae) { if (executionContext.getClientExecutionTrackerTask().hasTimeoutExpired()) { return new ClientExecutionTimeoutException(); } else { Thread.currentThread().interrupt(); return ae; } }
/** * 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); } }
/** * Start and end client execution timer around the execution of the request. It's important * that the client execution task is canceled before the InterruptedExecption is handled by * {@link #execute()} so * the interrupt status doesn't leak out to the callers code */ private Response<Output> executeWithTimer() throws InterruptedException { ClientExecutionAbortTrackerTask clientExecutionTrackerTask = clientExecutionTimer.startTimer(getClientExecutionTimeout(requestConfig)); try { executionContext.setClientExecutionTrackerTask(clientExecutionTrackerTask); return doExecute(); } finally { executionContext.getClientExecutionTrackerTask().cancelTask(); } }
executionContext.getClientExecutionTrackerTask().setCurrentHttpRequest(execOneParams.apacheRequest); final HttpRequestAbortTaskTracker requestAbortTaskTracker = httpRequestTimer .startTimer(execOneParams.apacheRequest, getRequestTimeout(requestConfig)); if (executionContext.getClientExecutionTrackerTask().hasTimeoutExpired()) { throw new InterruptedException(); } else if (requestAbortTaskTracker.httpRequestAborted()) {