hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1229172 - /httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/MemcachedHttpCacheStorage.java
Date Mon, 09 Jan 2012 14:33:09 GMT
Author: jonm
Date: Mon Jan  9 14:33:08 2012
New Revision: 1229172

URL: http://svn.apache.org/viewvc?rev=1229172&view=rev
Log:
HTTPCLIENT-1152: Log a WARN-level message if memcached gives us back something other
than a byte[].

Modified:
    httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/MemcachedHttpCacheStorage.java

Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/MemcachedHttpCacheStorage.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/MemcachedHttpCacheStorage.java?rev=1229172&r1=1229171&r2=1229172&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/MemcachedHttpCacheStorage.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/MemcachedHttpCacheStorage.java
Mon Jan  9 14:33:08 2012
@@ -37,6 +37,8 @@ import net.spy.memcached.CASValue;
 import net.spy.memcached.MemcachedClient;
 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.HttpCacheEntrySerializer;
 import org.apache.http.client.cache.HttpCacheUpdateException;
@@ -74,6 +76,8 @@ import org.apache.http.impl.client.cache
  */
 public class MemcachedHttpCacheStorage implements HttpCacheStorage {
 
+    private static final Log log = LogFactory.getLog(MemcachedHttpCacheStorage.class);
+    
     private final MemcachedClientIF client;
     private final HttpCacheEntrySerializer serializer;
     private final int maxUpdateRetries;
@@ -141,8 +145,14 @@ public class MemcachedHttpCacheStorage i
         do {
 
             CASValue<Object> v = client.gets(url);
-            byte[] oldBytes = (v != null && (v.getValue() instanceof byte[])) ? (byte[])
v.getValue() :
-                    null;
+            byte[] oldBytes = 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;
             if (oldBytes != null) {
                 ByteArrayInputStream bis = new ByteArrayInputStream(oldBytes);



Mime
View raw message