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 2023/08/20 09:42:43 UTC
[httpcomponents-client] 31/38: Fixed a logical error that can cause a NPE
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a commit to branch 5.4.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git
commit cbc96f8783587526a06dfe9dabfd68b1f043e803
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Sun Jun 18 17:11:22 2023 +0200
Fixed a logical error that can cause a NPE
---
.../java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java | 3 +--
.../main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
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 4839b9f05..24562c3ac 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
@@ -673,8 +673,7 @@ class AsyncCachingExec extends CachingExecBase implements AsyncExecChainHandler
final boolean staleIfErrorEnabled = responseCachingPolicy.isStaleIfErrorEnabled(responseCacheControl, entry);
if (cacheRevalidator != null
&& !staleResponseNotAllowed(requestCacheControl, responseCacheControl, entry, now)
- && validityPolicy.mayReturnStaleWhileRevalidating(responseCacheControl, entry, now)
- || staleIfErrorEnabled) {
+ && (validityPolicy.mayReturnStaleWhileRevalidating(responseCacheControl, entry, now) || staleIfErrorEnabled)) {
LOG.debug("Serving stale with asynchronous revalidation");
try {
final SimpleHttpResponse cacheResponse = generateCachedResponse(responseCacheControl, request, context, entry, now);
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 d21c969d0..869db843a 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
@@ -281,8 +281,7 @@ class CachingExec extends CachingExecBase implements ExecChainHandler {
try {
if (cacheRevalidator != null
&& !staleResponseNotAllowed(requestCacheControl, responseCacheControl, entry, now)
- && validityPolicy.mayReturnStaleWhileRevalidating(responseCacheControl, entry, now)
- || staleIfErrorEnabled) {
+ && (validityPolicy.mayReturnStaleWhileRevalidating(responseCacheControl, entry, now) || staleIfErrorEnabled)) {
LOG.debug("Serving stale with asynchronous revalidation");
final String exchangeId = ExecSupport.getNextExchangeId();
context.setExchangeId(exchangeId);