You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2018/01/01 16:01:45 UTC

[3/3] httpcomponents-client git commit: Corrected handling of request with non-repeatable by caching request execution interceptors

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


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/commit/194e4f52
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/tree/194e4f52
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/diff/194e4f52

Branch: refs/heads/master
Commit: 194e4f528973a7139c178f198fde644d4ea03cb3
Parents: c607197
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Mon Jan 1 16:52:50 2018 +0100
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Mon Jan 1 16:52:50 2018 +0100

----------------------------------------------------------------------
 .../org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java | 5 +++--
 .../java/org/apache/hc/client5/http/impl/cache/CachingExec.java | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/194e4f52/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java
index 179fbcd..c812b12 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java
@@ -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);

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/194e4f52/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java
index 724fa8a..7fb7e42 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java
@@ -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);