[
https://issues.apache.org/jira/browse/HTTPCLIENT-2327?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Oleg Kalnichevski resolved HTTPCLIENT-2327.
-------------------------------------------
Fix Version/s: 5.4-alpha3
Resolution: Fixed
> MemcachedHttpAsyncCacheStorage propagates CancellationException from
> cancelled cache requests to caller
> -------------------------------------------------------------------------------------------------------
>
> Key: HTTPCLIENT-2327
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2327
> Project: HttpComponents HttpClient
> Issue Type: Bug
> Components: HttpCache
> Reporter: Jovan Attisha
> Priority: Major
> Fix For: 5.4-alpha3
>
> Time Spent: 40m
> Remaining Estimate: 0h
>
> Spymemcached provides options to handle failure modes when an in-flight
> request to a Memcached instance fails (for example, when deploying to a
> Memcached server that is currently serving requests). One of the modes, and
> the most logical for our scenario in particular, is
> [Cancel|https://github.com/couchbase/spymemcached/blob/master/src/main/java/net/spy/memcached/FailureMode.java#L51-L54].
> This, as you would expect, cancels any futures that are in-flight when a
> Memcached node becomes unreachable.
>
> The issue that we're having is that the
> {{[MemcachedHttpAsyncCacheStorage|https://github.com/apache/httpcomponents-client/blob/master/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpAsyncCacheStorage.java#L184]}}
> (for restore linked here, as this is our issue, but also for other methods),
> doesn't handle the {{CancellationException}} gracefully, and instead
> propagates this Exception up to the caller. Since this is a cache for an HTTP
> client, I would expect the client to handle the cancellation as a "cache
> miss" (I would almost expect this behavior for {_}all exceptions{_}, though
> I'm likely not thinking of some edge cases here) and proceed to make the
> request to the resource originally requested, since the cache is a mere
> optimization, and a failure in the cache should not impact the actual request
> to the resource we're targeting.
>
> We did POC this by extending the
> {{[MemcachedHttpAsyncCacheStorage|https://github.com/apache/httpcomponents-client/blob/master/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpAsyncCacheStorage.java#L184]}}
> and overriding the {{restore}} method to explicitly handle
> {{{}CancellationException{}}}s and complete the future to treat it as a cache
> miss, but before we proceed with this, we want to understand if:
> 1. The Apache HTTPClient agrees that this is the desired behavior
> 2. If so, would the Apache HTTP Client accept this behavior in the client
> itself, rather than us extending to override this behavior
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]