hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1229179 - in /httpcomponents/httpclient/branches/4.1.x: ./ httpclient-cache/ httpclient-cache/src/main/java/org/apache/http/client/cache/ httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ httpclient-cache/src/main/java/org/...
Date Mon, 09 Jan 2012 14:44:47 GMT
Author: jonm
Date: Mon Jan  9 14:44:46 2012
New Revision: 1229179

URL: http://svn.apache.org/viewvc?rev=1229179&view=rev
Log:
HTTPCLIENT-1152: Backport of fix to 4.1.x release branch.

Modified:
    httpcomponents/httpclient/branches/4.1.x/   (props changed)
    httpcomponents/httpclient/branches/4.1.x/RELEASE_NOTES.txt
    httpcomponents/httpclient/branches/4.1.x/httpclient/   (props changed)
    httpcomponents/httpclient/branches/4.1.x/httpclient-cache/   (props changed)
    httpcomponents/httpclient/branches/4.1.x/httpclient-cache/src/main/java/org/apache/http/client/cache/HttpCacheStorage.java
  (props changed)
    httpcomponents/httpclient/branches/4.1.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCacheStorage.java
  (props changed)
    httpcomponents/httpclient/branches/4.1.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/MemcachedHttpCacheStorage.java
    httpcomponents/httpclient/branches/4.1.x/httpclient-contrib/src/main/java/org/apache/http/contrib/auth/BouncySpnegoTokenGenerator.java
  (props changed)
    httpcomponents/httpclient/branches/4.1.x/httpclient/src/main/java/org/apache/http/impl/conn/HttpInetSocketAddress.java
  (props changed)
    httpcomponents/httpclient/branches/4.1.x/httpclient/src/test/resources/test.keystore 
 (props changed)
    httpcomponents/httpclient/branches/4.1.x/src/docbkx/resources/   (props changed)
    httpcomponents/httpclient/branches/4.1.x/src/site/   (props changed)
    httpcomponents/httpclient/branches/4.1.x/src/site/apt/ntlm.apt   (props changed)

Propchange: httpcomponents/httpclient/branches/4.1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan  9 14:44:46 2012
@@ -1,4 +1,4 @@
 /httpcomponents/httpclient/branches/4.0.x:950681-950688
 /httpcomponents/httpclient/branches/branch_4_1:755593-811107
 /httpcomponents/httpclient/branches/notice-plugin-test:1024348-1031454
-/httpcomponents/httpclient/trunk:1087358,1091140-1091141,1091904,1104207-1104211,1132902-1132903,1133907,1138790-1138791,1147280,1198939,1198941
+/httpcomponents/httpclient/trunk:1087358,1091140-1091141,1091904,1104207-1104211,1132902-1132903,1133907,1138790-1138791,1147280,1198939,1198941,1229169,1229172,1229176

Modified: httpcomponents/httpclient/branches/4.1.x/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.1.x/RELEASE_NOTES.txt?rev=1229179&r1=1229178&r2=1229179&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.1.x/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpclient/branches/4.1.x/RELEASE_NOTES.txt Mon Jan  9 14:44:46 2012
@@ -1,5 +1,8 @@
 Changes since 4.1.2
 -------------------
+* [HTTPCLIENT-1152] MemcachedHttpCacheStorage should verify class of
+  returned object before casting.
+  Contributed by Rajika Kumarasiri <rajika at wso2 dot com>.
 
 * [HTTPCLIENT-1155] CachingHttpClient fails to ensure that the response content gets fully
consumed 
   when using a ResponseHandler, which can potentially lead to connection leaks.

Propchange: httpcomponents/httpclient/branches/4.1.x/httpclient/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan  9 14:44:46 2012
@@ -1,4 +1,4 @@
 /httpcomponents/httpclient/branches/4.0.x/httpclient:950681-950688
 /httpcomponents/httpclient/branches/branch_4_1/httpclient:755593-811107
 /httpcomponents/httpclient/branches/notice-plugin-test/httpclient:1024348-1031454
-/httpcomponents/httpclient/trunk/httpclient:1087358,1088000-1088004,1091140-1091141,1091904,1100531-1100533,1104207-1104211,1132902-1132903,1138790-1138791,1147280,1198939,1198941
+/httpcomponents/httpclient/trunk/httpclient:1087358,1088000-1088004,1091140-1091141,1091904,1100531-1100533,1104207-1104211,1132902-1132903,1138790-1138791,1147280,1198939,1198941,1229169,1229172,1229176

Propchange: httpcomponents/httpclient/branches/4.1.x/httpclient-cache/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan  9 14:44:46 2012
@@ -1,4 +1,4 @@
 /httpcomponents/httpclient/branches/4.0.x/httpclient-cache:950681-950688
 /httpcomponents/httpclient/branches/branch_4_1/httpclient-cache:755593-811107
 /httpcomponents/httpclient/branches/notice-plugin-test/httpclient-cache:1024348-1031454
-/httpcomponents/httpclient/trunk/httpclient-cache:1080419,1080422,1080575,1084590,1084607,1084610-1084611,1084649,1084655,1087358,1133907,1147280,1198939,1198941
+/httpcomponents/httpclient/trunk/httpclient-cache:1080419,1080422,1080575,1084590,1084607,1084610-1084611,1084649,1084655,1087358,1133907,1147280,1198939,1198941,1229169,1229172,1229176

Propchange: httpcomponents/httpclient/branches/4.1.x/httpclient-cache/src/main/java/org/apache/http/client/cache/HttpCacheStorage.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan  9 14:44:46 2012
@@ -1,3 +1,3 @@
 /httpcomponents/httpclient/branches/4.0.x/httpclient-cache/src/main/java/org/apache/http/client/cache/HttpCache.java:950681-950688
 /httpcomponents/httpclient/branches/branch_4_1/httpclient-cache/src/main/java/org/apache/http/client/cache/HttpCache.java:755593-811107
-/httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/client/cache/HttpCacheStorage.java:1080419,1080422,1080575,1084590,1084607,1084610-1084611,1084649,1084655,1087358,1147280,1198939,1198941
+/httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/client/cache/HttpCacheStorage.java:1080419,1080422,1080575,1084590,1084607,1084610-1084611,1084649,1084655,1087358,1147280,1198939,1198941,1229169,1229172,1229176

Propchange: httpcomponents/httpclient/branches/4.1.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCacheStorage.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan  9 14:44:46 2012
@@ -1,3 +1,3 @@
 /httpcomponents/httpclient/branches/4.0.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCache.java:950681-950688
 /httpcomponents/httpclient/branches/branch_4_1/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCache.java:755593-811107
-/httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCacheStorage.java:1080419,1080422,1080575,1084590,1084607,1084610-1084611,1084649,1084655,1087358,1147280,1198939,1198941
+/httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCacheStorage.java:1080419,1080422,1080575,1084590,1084607,1084610-1084611,1084649,1084655,1087358,1147280,1198939,1198941,1229169,1229172,1229176

Modified: httpcomponents/httpclient/branches/4.1.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/MemcachedHttpCacheStorage.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.1.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/MemcachedHttpCacheStorage.java?rev=1229179&r1=1229178&r2=1229179&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.1.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/MemcachedHttpCacheStorage.java
(original)
+++ httpcomponents/httpclient/branches/4.1.x/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/MemcachedHttpCacheStorage.java
Mon Jan  9 14:44:46 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;
@@ -84,7 +88,7 @@ public class MemcachedHttpCacheStorage i
      * just have a single local memcached instance running on the same
      * machine as your application, for example.
      * @param address where the <i>memcached</i> daemon is running
-     * @throws IOException
+     * @throws IOException in case of an error
      */
     public MemcachedHttpCacheStorage(InetSocketAddress address) throws IOException {
         this(new MemcachedClient(address));
@@ -138,32 +142,39 @@ public class MemcachedHttpCacheStorage i
     public void updateEntry(String url, HttpCacheUpdateCallback callback)
             throws HttpCacheUpdateException, IOException {
         int numRetries = 0;
-        do{
+        do {
 
-        CASValue<Object> v = client.gets(url);
-        byte[] oldBytes = (v != null) ? (byte[]) v.getValue() : null;
-        HttpCacheEntry existingEntry = null;
-        if (oldBytes != null) {
-            ByteArrayInputStream bis = new ByteArrayInputStream(oldBytes);
-            existingEntry = serializer.readFrom(bis);
-        }
-        HttpCacheEntry updatedEntry = callback.update(existingEntry);
-
-        if (v == null) {
-            putEntry(url, updatedEntry);
-            return;
-
-        } else {
-            ByteArrayOutputStream bos = new ByteArrayOutputStream();
-            serializer.writeTo(updatedEntry, bos);
-            CASResponse casResult = client.cas(url, v.getCas(), bos.toByteArray());
-            if (casResult != CASResponse.OK) {
-                 numRetries++;
+            CASValue<Object> v = client.gets(url);
+            byte[] oldBytes = null;
+            if (v != null) {
+                if (v.getValue() instanceof byte[]) {
+                    oldBytes = (byte[])v.getValue();
+                } else {
+                    log.warn("got non-bytearray back from memcached");
+                }
             }
-            else return;
-        }
+            HttpCacheEntry existingEntry = null;
+            if (oldBytes != null) {
+                ByteArrayInputStream bis = new ByteArrayInputStream(oldBytes);
+                existingEntry = serializer.readFrom(bis);
+            }
+            HttpCacheEntry updatedEntry = callback.update(existingEntry);
+
+            if (v == null) {
+                putEntry(url, updatedEntry);
+                return;
+
+            } else {
+                ByteArrayOutputStream bos = new ByteArrayOutputStream();
+                serializer.writeTo(updatedEntry, bos);
+                CASResponse casResult = client.cas(url, v.getCas(), bos.toByteArray());
+                if (casResult != CASResponse.OK) {
+                    numRetries++;
+                } else return;
+            }
+
+        } while (numRetries <= maxUpdateRetries);
 
-    } while(numRetries <= maxUpdateRetries);
-    throw new HttpCacheUpdateException("Failed to update");
+        throw new HttpCacheUpdateException("Failed to update");
     }
 }
\ No newline at end of file

Propchange: httpcomponents/httpclient/branches/4.1.x/httpclient-contrib/src/main/java/org/apache/http/contrib/auth/BouncySpnegoTokenGenerator.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan  9 14:44:46 2012
@@ -1,2 +1,2 @@
 /httpcomponents/httpclient/branches/branch_4_1/contrib/org/apache/http/contrib/auth/BouncySpnegoTokenGenerator.java:755593-811107
-/httpcomponents/httpclient/trunk/httpclient-contrib/src/main/java/org/apache/http/contrib/auth/BouncySpnegoTokenGenerator.java:1087358,1147280,1198939,1198941
+/httpcomponents/httpclient/trunk/httpclient-contrib/src/main/java/org/apache/http/contrib/auth/BouncySpnegoTokenGenerator.java:1087358,1147280,1198939,1198941,1229169,1229172,1229176

Propchange: httpcomponents/httpclient/branches/4.1.x/httpclient/src/main/java/org/apache/http/impl/conn/HttpInetSocketAddress.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan  9 14:44:46 2012
@@ -2,4 +2,4 @@
 /httpcomponents/httpclient/branches/4.1.x/httpclient/src/main/java/org/apache/http/conn/HttpInetSocketAddress.java:1079518-1080165
 /httpcomponents/httpclient/branches/branch_4_1/httpclient/src/main/java/org/apache/http/conn/HttpInetSocketAddress.java:755593-811107
 /httpcomponents/httpclient/branches/notice-plugin-test/httpclient/src/main/java/org/apache/http/conn/HttpInetSocketAddress.java:1024348-1031454
-/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpInetSocketAddress.java:1147280,1198939,1198941
+/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpInetSocketAddress.java:1147280,1198939,1198941,1229169,1229172,1229176

Propchange: httpcomponents/httpclient/branches/4.1.x/httpclient/src/test/resources/test.keystore
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan  9 14:44:46 2012
@@ -1,2 +1,2 @@
-/httpcomponents/httpclient/trunk/httpclient/src/test/resources/test.keystore:1087358,1132902-1132903,1147280,1198939,1198941
+/httpcomponents/httpclient/trunk/httpclient/src/test/resources/test.keystore:1087358,1132902-1132903,1147280,1198939,1198941,1229169,1229172,1229176
 /httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/test/resources/test.keystore:755687-758898

Propchange: httpcomponents/httpclient/branches/4.1.x/src/docbkx/resources/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan  9 14:44:46 2012
@@ -1,2 +1,2 @@
-/httpcomponents/httpclient/trunk/src/docbkx/resources:1087358,1147280,1198939,1198941
+/httpcomponents/httpclient/trunk/src/docbkx/resources:1087358,1147280,1198939,1198941,1229169,1229172,1229176
 /httpcomponents/httpcore/branches/ibm_compat_branch/src/docbkx/resources:755687-758898

Propchange: httpcomponents/httpclient/branches/4.1.x/src/site/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan  9 14:44:46 2012
@@ -1,4 +1,4 @@
 /httpcomponents/httpclient/branches/4.0.x/src/site:950681-950688
 /httpcomponents/httpclient/branches/branch_4_1/src/site:755593-811107
 /httpcomponents/httpclient/branches/notice-plugin-test/src/site:1024348-1031454
-/httpcomponents/httpclient/trunk/src/site:1087358,1091140-1091141,1091904,1095921-1100531,1147280,1198939,1198941
+/httpcomponents/httpclient/trunk/src/site:1087358,1091140-1091141,1091904,1095921-1100531,1147280,1198939,1198941,1229169,1229172,1229176

Propchange: httpcomponents/httpclient/branches/4.1.x/src/site/apt/ntlm.apt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan  9 14:44:46 2012
@@ -1 +1 @@
-/httpcomponents/httpclient/trunk/src/site/apt/ntlm.apt:825864-828185,954258,956989-957002,1147280,1198939,1198941
+/httpcomponents/httpclient/trunk/src/site/apt/ntlm.apt:825864-828185,954258,956989-957002,1147280,1198939,1198941,1229169,1229172,1229176



Mime
View raw message