Corrected handling of request with non-repeatable by caching request execution interceptors

This commit is contained in:
Oleg Kalnichevski 2018-01-01 16:52:50 +01:00
parent c607197fd0
commit 194e4f5289
2 changed files with 5 additions and 3 deletions

View File

@ -711,7 +711,8 @@ public class AsyncCachingExec extends CachingExecBase implements AsyncExecChainH
final Date responseDate1 = getCurrentDate();
final AsyncExecCallback callback1;
if (revalidationResponseIsTooOld(backendResponse1, cacheEntry)) {
if (revalidationResponseIsTooOld(backendResponse1, cacheEntry)
&& (entityProducer == null || entityProducer.isRepeatable())) {
final HttpRequest unconditional = conditionalRequestBuilder.buildUnconditionalRequest(
scope.originalRequest);
@ -805,7 +806,7 @@ public class AsyncCachingExec extends CachingExecBase implements AsyncExecChainH
@Override
public void completed(final Map<String, Variant> variants) {
if (variants != null && !variants.isEmpty()) {
if (variants != null && !variants.isEmpty() && (entityProducer == null || entityProducer.isRepeatable())) {
negotiateResponseFromVariants(target, request, entityProducer, scope, chain, asyncExecCallback, variants);
} else {
callBackend(target, request, entityProducer, scope, chain, asyncExecCallback);

View File

@ -447,7 +447,8 @@ public class CachingExec extends CachingExecBase implements ExecChainHandler {
return callBackend(target, request, scope, chain);
}
if (revalidationResponseIsTooOld(backendResponse, matchingVariant.getEntry())) {
if (revalidationResponseIsTooOld(backendResponse, matchingVariant.getEntry())
&& (request.getEntity() == null || request.getEntity().isRepeatable())) {
EntityUtils.consume(backendResponse.getEntity());
backendResponse.close();
final ClassicHttpRequest unconditional = conditionalRequestBuilder.buildUnconditionalRequest(request);