[ 
https://issues.apache.org/jira/browse/HTTPCLIENT-2327?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17846669#comment-17846669
 ] 

Jovan Attisha edited comment on HTTPCLIENT-2327 at 5/15/24 2:54 PM:
--------------------------------------------------------------------

Oh, interesting! I think you're right on that. In that case, it sounds like a 
{{CancellationException}} received by {{GetEntry}} for 
[MemcachedHttpAsyncCacheStorage|https://github.com/apache/httpcomponents-client/blob/master/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpAsyncCacheStorage.java]
 should be wrapped in a {{{}ResourceIOException{}}}, since this is behavior 
specific to Spymemcached, would you agree?

Edit: I think this would logically be extended to all methods of [this 
interface|https://github.com/apache/httpcomponents-client/blob/master/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpAsyncCacheStorage.java#L49],
 not just GetEntry.


was (Author: JIRAUSER286168):
Oh, interesting! I think you're right on that. In that case, it sounds like a 
{{CancellationException}} received by {{GetEntry}} for 
[MemcachedHttpAsyncCacheStorage|https://github.com/apache/httpcomponents-client/blob/master/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpAsyncCacheStorage.java]
 should be wrapped in a {{{}ResourceIOException{}}}, since this is behavior 
specific to Spymemcached, would you agree?

> 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
>
> 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: dev-unsubscr...@hc.apache.org
For additional commands, e-mail: dev-h...@hc.apache.org

Reply via email to