hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1229360 - 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 21:27:03 GMT
Author: jonm
Date: Mon Jan  9 21:27:02 2012
New Revision: 1229360

URL: http://svn.apache.org/viewvc?rev=1229360&view=rev
Log:
HTTPCLIENT-1152: Backport of r1229203 to 4.1.x branch. Also apply type check
before byte[] cast on memcached retrieval.

Modified:
    httpcomponents/httpclient/branches/4.1.x/   (props changed)
    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 21:27:02 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,1229169,1229172,1229176
+/httpcomponents/httpclient/trunk:1087358,1091140-1091141,1091904,1104207-1104211,1132902-1132903,1133907,1138790-1138791,1147280,1198939,1198941,1229169,1229172,1229176,1229203

Propchange: httpcomponents/httpclient/branches/4.1.x/httpclient/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan  9 21:27:02 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,1229169,1229172,1229176
+/httpcomponents/httpclient/trunk/httpclient:1087358,1088000-1088004,1091140-1091141,1091904,1100531-1100533,1104207-1104211,1132902-1132903,1138790-1138791,1147280,1198939,1198941,1229169,1229172,1229176,1229203

Propchange: httpcomponents/httpclient/branches/4.1.x/httpclient-cache/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan  9 21:27:02 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,1229169,1229172,1229176
+/httpcomponents/httpclient/trunk/httpclient-cache:1080419,1080422,1080575,1084590,1084607,1084610-1084611,1084649,1084655,1087358,1133907,1147280,1198939,1198941,1229169,1229172,1229176,1229203

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 21:27:02 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,1229169,1229172,1229176
+/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,1229203

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 21:27:02 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,1229169,1229172,1229176
+/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,1229203

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=1229360&r1=1229359&r2=1229360&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 21:27:02 2012
@@ -127,13 +127,25 @@ public class MemcachedHttpCacheStorage i
         client.set(url, 0, bos.toByteArray());
     }
 
-    public HttpCacheEntry getEntry(String url) throws IOException {
-        byte[] data = (byte[]) client.get(url);
-        if (null == data)
+    private byte[] convertToByteArray(Object o) {
+        if (o == null) return null;
+        if (!(o instanceof byte[])) {
+            log.warn("got a non-bytearray back from memcached: " + o);
             return null;
-        InputStream bis = new ByteArrayInputStream(data);
+        }
+        return (byte[])o;
+    }
+
+    private HttpCacheEntry reconstituteEntry(Object o) throws IOException {
+        byte[] out = convertToByteArray(o);
+        if (out == null) return null;
+        InputStream bis = new ByteArrayInputStream(out);
         return serializer.readFrom(bis);
     }
+    
+    public HttpCacheEntry getEntry(String url) throws IOException {
+        return reconstituteEntry(client.get(url));
+    }
 
     public void removeEntry(String url) throws IOException {
         client.delete(url);
@@ -145,19 +157,8 @@ public class MemcachedHttpCacheStorage i
         do {
 
             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");
-                }
-            }
-            HttpCacheEntry existingEntry = null;
-            if (oldBytes != null) {
-                ByteArrayInputStream bis = new ByteArrayInputStream(oldBytes);
-                existingEntry = serializer.readFrom(bis);
-            }
+            HttpCacheEntry existingEntry = (v == null) ? null
+                    : reconstituteEntry(v.getValue());
             HttpCacheEntry updatedEntry = callback.update(existingEntry);
 
             if (v == null) {

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 21:27:02 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,1229169,1229172,1229176
+/httpcomponents/httpclient/trunk/httpclient-contrib/src/main/java/org/apache/http/contrib/auth/BouncySpnegoTokenGenerator.java:1087358,1147280,1198939,1198941,1229169,1229172,1229176,1229203

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 21:27:02 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,1229169,1229172,1229176
+/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpInetSocketAddress.java:1147280,1198939,1198941,1229169,1229172,1229176,1229203

Propchange: httpcomponents/httpclient/branches/4.1.x/httpclient/src/test/resources/test.keystore
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan  9 21:27:02 2012
@@ -1,2 +1,2 @@
-/httpcomponents/httpclient/trunk/httpclient/src/test/resources/test.keystore:1087358,1132902-1132903,1147280,1198939,1198941,1229169,1229172,1229176
+/httpcomponents/httpclient/trunk/httpclient/src/test/resources/test.keystore:1087358,1132902-1132903,1147280,1198939,1198941,1229169,1229172,1229176,1229203
 /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 21:27:02 2012
@@ -1,2 +1,2 @@
-/httpcomponents/httpclient/trunk/src/docbkx/resources:1087358,1147280,1198939,1198941,1229169,1229172,1229176
+/httpcomponents/httpclient/trunk/src/docbkx/resources:1087358,1147280,1198939,1198941,1229169,1229172,1229176,1229203
 /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 21:27:02 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,1229169,1229172,1229176
+/httpcomponents/httpclient/trunk/src/site:1087358,1091140-1091141,1091904,1095921-1100531,1147280,1198939,1198941,1229169,1229172,1229176,1229203

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



Mime
View raw message