abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r561075 - /incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/AbderaClient.java
Date Mon, 30 Jul 2007 18:04:49 GMT
Author: jmsnell
Date: Mon Jul 30 11:04:48 2007
New Revision: 561075

URL: http://svn.apache.org/viewvc?view=rev&rev=561075
Log:
Bug in the logic for setting the max connections per host

Modified:
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/AbderaClient.java

Modified: incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/AbderaClient.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/AbderaClient.java?view=diff&rev=561075&r1=561074&r2=561075
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/AbderaClient.java
(original)
+++ incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/AbderaClient.java
Mon Jul 30 11:04:48 2007
@@ -20,7 +20,9 @@
 import java.io.InputStream;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import javax.net.ssl.TrustManager;
 
@@ -40,6 +42,7 @@
 import org.apache.abdera.util.ServiceUtil;
 import org.apache.abdera.util.Version;
 import org.apache.commons.httpclient.Credentials;
+import org.apache.commons.httpclient.HostConfiguration;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpMethod;
 import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
@@ -487,17 +490,24 @@
    * Set the maximum number of connections allowed for a single host
    */
   public void setMaxConnectionsPerHost(int max) {
-    client.getHttpConnectionManager().getParams().setIntParameter(
-      HttpConnectionManagerParams.MAX_HOST_CONNECTIONS, max);
+    Map<HostConfiguration,Integer> m = new HashMap<HostConfiguration,Integer>();
+    m.put(HostConfiguration.ANY_HOST_CONFIGURATION, max);
+    client.getHttpConnectionManager().getParams().setParameter(
+      HttpConnectionManagerParams.MAX_HOST_CONNECTIONS, m);
   }
   
   /**
    * Return the maximum number of connections allowed for a single host
    */
+  
+  @SuppressWarnings("unchecked")
   public int getMaxConnectionsPerHost() {
-    return client.getHttpConnectionManager().getParams().getIntParameter(
-      HttpConnectionManagerParams.MAX_HOST_CONNECTIONS,
-      MultiThreadedHttpConnectionManager.DEFAULT_MAX_HOST_CONNECTIONS);
+    Map<HostConfiguration,Integer> m = (Map<HostConfiguration,Integer>) 
+      client.getHttpConnectionManager().getParams().getParameter(
+        HttpConnectionManagerParams.MAX_HOST_CONNECTIONS);
+    if (m == null) return MultiThreadedHttpConnectionManager.DEFAULT_MAX_HOST_CONNECTIONS;
+    Integer i = m.get(HostConfiguration.ANY_HOST_CONFIGURATION);
+    return i != null ? i.intValue() : MultiThreadedHttpConnectionManager.DEFAULT_MAX_HOST_CONNECTIONS;
   }
   
   /**



Mime
View raw message