[ 
https://issues.apache.org/jira/browse/HTTPCLIENT-1152?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Oleg Kalnichevski resolved HTTPCLIENT-1152.
-------------------------------------------

       Resolution: Invalid
    Fix Version/s:     (was: 4.1.3)
                       (was: 4.2 Final)

> Could be that somebody is using the cache for other purposes as well, and 
> just happens to set an object with a URL as a key that
> conflicts with an object that is set by MemcachedHttpCacheStorage

Could be that somebody is using computer to hammer nails. We can't stop people 
from doing silly stuff.

>  -- this could (and also probably should) be mitigated by allowing the client 
> of MemcachedHttpCacheStorage to set a client-defined 
> prefix String that will be prefixed to all keys, thus avoiding potential 
> collisions. 

This is actually a very reasonable suggestion. Probably what we need is a 
generic strategy that can be used to generate a unique cache key from a request 
url. This would also take care of HTTPCLIENT-1153.

> In my case, it is that we are using jmemcacheddaemon for local testing 
> purposes, and (unfortunately) jmemcacheddaemon has 
> a known bug where cache misses return an empty string instead of a null 
> object. 

OK. But I do not think that polluting a general purpose library with a hack 
clearly specific to your local environment is the right thing to do. Simply 
implement a custom HttpCacheStorage which is aware of the empty string 
semantics.

Oleg
                
> org.apache.http.impl.client.cache.memcached.MemcachedHttpCacheStorage should 
> verify class of returned object before casting
> ---------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1152
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1152
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: Cache, HttpClient
>    Affects Versions: 4.1.1
>            Reporter: Clinton Nielsen
>            Assignee: Jon Moore
>         Attachments: HTTPCLIENT-1152.patch
>
>
> org.apache.http.impl.client.cache.memcached.MemcachedHttpCacheStorage
> Original (in getEntry function): 
>   byte[] data = (byte[]) client.get(url);
> Should be:
>   Object obj= client.get(url);
>   if (null == obj || !(objinstanceof byte[])) {
>     return null;
>   }
>   byte[] data = (byte[])obj;
> Original (in updateEntry function):
>   byte[] oldBytes = (v != null) ? (byte[]) v.getValue() : null;
> Should be:
>   byte[] oldBytes = (v != null && (v.getValue() instanceof byte[])) ? 
> (byte[]) v.getValue() : null;
>   

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to