@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try { // the execute method call flow if (isExecuteMethod(method)) { final HttpRequest httpRequest = invokeExecuteMethod(args); final HttpResponse response = client.execute(httpRequest); return new ApiResponse(response); } else { final HttpRequest httpRequest = createHttpRequest(method, args); final HttpResponse response = client.execute(httpRequest); return handleResponse(response, method); } } catch (final ApiClientException ace) { throw ace; } catch (final Exception e) { final String msg = e.getMessage() == null ? "" : e.getMessage(); throw new ApiClientException(msg, e); } }
@Test public void testRetryIOExceptionFromExecute() throws IOException { IOException exception = new IOException("BOOM"); EasyMock .expect(httpClient.execute(EasyMock.<HttpRequest> anyObject())) .andThrow(exception) .times(4); EasyMock.replay(httpClient); ExecutionContext context = new ExecutionContext(); Request<?> request = new DefaultRequest<Object>("testsvc"); request.setEndpoint(java.net.URI.create( "http://testsvc.region.amazonaws.com")); request.addHeader(HttpHeader.CONTENT_LENGTH, "0"); request.setContent(new ByteArrayInputStream(new byte[0])); try { client.execute(request, null, null, context); Assert.fail("No exception when request repeatedly fails!"); } catch (AmazonClientException e) { Assert.assertSame(exception, e.getCause()); } // Verify that we called execute 4 times. EasyMock.verify(httpClient); }
.expect(httpClient.execute(EasyMock.<HttpRequest> anyObject())) .andReturn(response) .times(4);
awsRequestMetrics.startEvent(Field.HttpRequestTime); try { httpResponse = httpClient.execute(httpRequest); } finally { awsRequestMetrics.endEvent(Field.HttpRequestTime);
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try { // the execute method call flow if (isExecuteMethod(method)) { final HttpRequest httpRequest = invokeExecuteMethod(args); final HttpResponse response = client.execute(httpRequest); return new ApiResponse(response); } else { final HttpRequest httpRequest = createHttpRequest(method, args); final HttpResponse response = client.execute(httpRequest); return handleResponse(response, method); } } catch (final ApiClientException ace) { throw ace; } catch (final Exception e) { final String msg = e.getMessage() == null ? "" : e.getMessage(); throw new ApiClientException(msg, e); } }
awsRequestMetrics.startEvent(Field.HttpRequestTime); try { httpResponse = httpClient.execute(httpRequest); } finally { awsRequestMetrics.endEvent(Field.HttpRequestTime);
awsRequestMetrics.startEvent(Field.HttpRequestTime); try { httpResponse = httpClient.execute(httpRequest); } finally { awsRequestMetrics.endEvent(Field.HttpRequestTime);