HTTPCLIENT-1152: Log a WARN-level message if memcached gives us back something other
than a byte[]. git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1229172 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a6fe2177be
commit
9f0bc2474f
|
@ -37,6 +37,8 @@ import net.spy.memcached.CASValue;
|
||||||
import net.spy.memcached.MemcachedClient;
|
import net.spy.memcached.MemcachedClient;
|
||||||
import net.spy.memcached.MemcachedClientIF;
|
import net.spy.memcached.MemcachedClientIF;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.http.client.cache.HttpCacheEntry;
|
import org.apache.http.client.cache.HttpCacheEntry;
|
||||||
import org.apache.http.client.cache.HttpCacheEntrySerializer;
|
import org.apache.http.client.cache.HttpCacheEntrySerializer;
|
||||||
import org.apache.http.client.cache.HttpCacheUpdateException;
|
import org.apache.http.client.cache.HttpCacheUpdateException;
|
||||||
|
@ -74,6 +76,8 @@ import org.apache.http.impl.client.cache.DefaultHttpCacheEntrySerializer;
|
||||||
*/
|
*/
|
||||||
public class MemcachedHttpCacheStorage implements HttpCacheStorage {
|
public class MemcachedHttpCacheStorage implements HttpCacheStorage {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(MemcachedHttpCacheStorage.class);
|
||||||
|
|
||||||
private final MemcachedClientIF client;
|
private final MemcachedClientIF client;
|
||||||
private final HttpCacheEntrySerializer serializer;
|
private final HttpCacheEntrySerializer serializer;
|
||||||
private final int maxUpdateRetries;
|
private final int maxUpdateRetries;
|
||||||
|
@ -141,8 +145,14 @@ public class MemcachedHttpCacheStorage implements HttpCacheStorage {
|
||||||
do {
|
do {
|
||||||
|
|
||||||
CASValue<Object> v = client.gets(url);
|
CASValue<Object> v = client.gets(url);
|
||||||
byte[] oldBytes = (v != null && (v.getValue() instanceof byte[])) ? (byte[]) v.getValue() :
|
byte[] oldBytes = null;
|
||||||
null;
|
if (v != null) {
|
||||||
|
if (v.getValue() instanceof byte[]) {
|
||||||
|
oldBytes = (byte[])v.getValue();
|
||||||
|
} else {
|
||||||
|
log.warn("got non-bytearray back from memcached");
|
||||||
|
}
|
||||||
|
}
|
||||||
HttpCacheEntry existingEntry = null;
|
HttpCacheEntry existingEntry = null;
|
||||||
if (oldBytes != null) {
|
if (oldBytes != null) {
|
||||||
ByteArrayInputStream bis = new ByteArrayInputStream(oldBytes);
|
ByteArrayInputStream bis = new ByteArrayInputStream(oldBytes);
|
||||||
|
|
Loading…
Reference in New Issue