Cleanups in CachingExec and related test classes

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1572556 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2014-02-27 13:32:58 +00:00
parent 9c02dde2cc
commit b3b1b712df
3 changed files with 8 additions and 16 deletions

View File

@ -579,8 +579,8 @@ public class CachingExec implements ClientExecChain {
final CloseableHttpResponse backendResponse = backend.execute(route, request, context, execAware); final CloseableHttpResponse backendResponse = backend.execute(route, request, context, execAware);
try { try {
backendResponse.addHeader("Via", generateViaHeader(backendResponse)); backendResponse.addHeader("Via", generateViaHeader(backendResponse));
return handleBackendResponse(route, request, context, execAware, return handleBackendResponse(request, context, requestDate, getCurrentDate(),
requestDate, getCurrentDate(), backendResponse); backendResponse);
} catch (final IOException ex) { } catch (final IOException ex) {
backendResponse.close(); backendResponse.close();
throw ex; throw ex;
@ -629,9 +629,8 @@ public class CachingExec implements ClientExecChain {
backendResponse.addHeader("Via", generateViaHeader(backendResponse)); backendResponse.addHeader("Via", generateViaHeader(backendResponse));
if (backendResponse.getStatusLine().getStatusCode() != HttpStatus.SC_NOT_MODIFIED) { if (backendResponse.getStatusLine().getStatusCode() != HttpStatus.SC_NOT_MODIFIED) {
return handleBackendResponse( return handleBackendResponse(request, context, requestDate, responseDate,
route, request, context, execAware, backendResponse);
requestDate, responseDate, backendResponse);
} }
final Header resultEtagHeader = backendResponse.getFirstHeader(HeaderConstants.ETAG); final Header resultEtagHeader = backendResponse.getFirstHeader(HeaderConstants.ETAG);
@ -784,9 +783,8 @@ public class CachingExec implements ClientExecChain {
backendResponse.close(); backendResponse.close();
} }
} }
return handleBackendResponse( return handleBackendResponse(conditionalRequest, context, requestDate, responseDate,
route, conditionalRequest, context, execAware, backendResponse);
requestDate, responseDate, backendResponse);
} }
private boolean staleIfErrorAppliesTo(final int statusCode) { private boolean staleIfErrorAppliesTo(final int statusCode) {
@ -797,10 +795,8 @@ public class CachingExec implements ClientExecChain {
} }
CloseableHttpResponse handleBackendResponse( CloseableHttpResponse handleBackendResponse(
final HttpRoute route,
final HttpRequestWrapper request, final HttpRequestWrapper request,
final HttpClientContext context, final HttpClientContext context,
final HttpExecutionAware execAware,
final Date requestDate, final Date requestDate,
final Date responseDate, final Date responseDate,
final CloseableHttpResponse backendResponse) throws IOException { final CloseableHttpResponse backendResponse) throws IOException {

View File

@ -262,10 +262,8 @@ public class TestCachingExec extends TestCachingExecChain {
backendExpectsRequestAndReturn(validate, originResponse); backendExpectsRequestAndReturn(validate, originResponse);
getCurrentDateReturns(responseDate); getCurrentDateReturns(responseDate);
expect(impl.handleBackendResponse( expect(impl.handleBackendResponse(
eq(route),
same(validate), same(validate),
same(context), same(context),
(HttpExecutionAware) isNull(),
eq(requestDate), eq(requestDate),
eq(responseDate), eq(responseDate),
same(originResponse))).andReturn(finalResponse); same(originResponse))).andReturn(finalResponse);
@ -404,10 +402,8 @@ public class TestCachingExec extends TestCachingExecChain {
throws IOException { throws IOException {
expect( expect(
impl.handleBackendResponse( impl.handleBackendResponse(
isA(HttpRoute.class),
same(request), same(request),
isA(HttpClientContext.class), isA(HttpClientContext.class),
(HttpExecutionAware) isNull(),
isA(Date.class), isA(Date.class),
isA(Date.class), isA(Date.class),
isA(CloseableHttpResponse.class))).andReturn( isA(CloseableHttpResponse.class))).andReturn(

View File

@ -106,7 +106,7 @@ public class TestHttpCacheJiraNumber1147 {
EasyMock.expect(backend.execute( EasyMock.expect(backend.execute(
EasyMock.eq(route), EasyMock.eq(route),
EasyMock.isA(HttpRequestWrapper.class), EasyMock.isA(HttpRequestWrapper.class),
EasyMock.same(context), EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(Proxies.enhanceResponse(response)); EasyMock.<HttpExecutionAware>isNull())).andReturn(Proxies.enhanceResponse(response));
EasyMock.replay(backend); EasyMock.replay(backend);
@ -125,7 +125,7 @@ public class TestHttpCacheJiraNumber1147 {
EasyMock.expect(backend.execute( EasyMock.expect(backend.execute(
EasyMock.eq(route), EasyMock.eq(route),
EasyMock.isA(HttpRequestWrapper.class), EasyMock.isA(HttpRequestWrapper.class),
EasyMock.same(context), EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(Proxies.enhanceResponse(response)); EasyMock.<HttpExecutionAware>isNull())).andReturn(Proxies.enhanceResponse(response));
EasyMock.replay(backend); EasyMock.replay(backend);