Return-Path: Delivered-To: apmail-hc-dev-archive@www.apache.org Received: (qmail 64750 invoked from network); 22 Feb 2010 19:47:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 22 Feb 2010 19:47:20 -0000 Received: (qmail 14310 invoked by uid 500); 22 Feb 2010 19:47:18 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 14278 invoked by uid 500); 22 Feb 2010 19:47:18 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 14230 invoked by uid 99); 22 Feb 2010 19:47:18 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Feb 2010 19:47:18 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of sberlin@gmail.com designates 209.85.220.211 as permitted sender) Received: from [209.85.220.211] (HELO mail-fx0-f211.google.com) (209.85.220.211) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Feb 2010 19:47:10 +0000 Received: by fxm3 with SMTP id 3so152596fxm.38 for ; Mon, 22 Feb 2010 11:46:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=3S7a981VTXRXH8XDgOB6gWWLFMLZDc8TjfFcRyRJh9s=; b=EdvUFXKDeqVu+o+gn8yt/lHcr1Lfle1aVl27BZjNlrVjiezqmKc8Sp5U6EisEdNgqh IiWZxroShEN8AGqUg/xE6f9AXPtds6RlKmt9EfvlulHVy2ermw0poTmni1H3xZz06DYK ubVZ1nPyxzEVRR7O1RMmjj8y5T5cAlXpgDLeg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=Lv58+bRNRxWKArWtryzXufF+ZijFnAw2EAOS4ZAQKRpE7gbto2JkdDPdu00QGIVsOg Z4trzhArh71kB/EaTX7cp/yf64fY8zAe3u5ZJEDUDkHMAUcAWk5K2JaACvEOP+6tjqjH Im5Sy6xyNuMO36irqv0ZzfJS7ZZYUmkY28vFQ= MIME-Version: 1.0 Received: by 10.223.63.193 with SMTP id c1mr5690073fai.80.1266868004876; Mon, 22 Feb 2010 11:46:44 -0800 (PST) In-Reply-To: <25aac9fc1002221136md7ffbfbla185088ad2eccdb9@mail.gmail.com> References: <20100222184555.925C823889C5@eris.apache.org> <25aac9fc1002221136md7ffbfbla185088ad2eccdb9@mail.gmail.com> Date: Mon, 22 Feb 2010 14:46:44 -0500 Message-ID: <19196d861002221146t57d3b11bo6798007c0d42a799@mail.gmail.com> Subject: Re: svn commit: r915013 - in /httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn: AbstractClientConnAdapter.java DefaultClientConnection.java From: Sam Berlin To: HttpComponents Project Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org ConcurrentHashMap has a high memory overhead (which has bitten me in projects before, where CHM was used for in many places convenience but wasn't strictly needed). Unless there's a compelling need to have a non-blocking threadsafe map, a synchronized hashmap should work well. Sam On Mon, Feb 22, 2010 at 2:36 PM, sebb wrote: > On 22/02/2010, olegk@apache.org wrote: >> Author: olegk >> =A0Date: Mon Feb 22 18:45:55 2010 >> =A0New Revision: 915013 >> >> =A0URL: http://svn.apache.org/viewvc?rev=3D915013&view=3Drev >> =A0Log: >> =A0HTTPCLIENT-915: mechanism to attatch user define attributes to connec= tions >> >> =A0Modified: >> =A0 =A0 httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apa= che/http/impl/conn/AbstractClientConnAdapter.java >> =A0 =A0 httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apa= che/http/impl/conn/DefaultClientConnection.java >> >> =A0Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/or= g/apache/http/impl/conn/AbstractClientConnAdapter.java >> =A0URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/htt= pclient/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.j= ava?rev=3D915013&r1=3D915012&r2=3D915013&view=3Ddiff >> =A0=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D >> =A0--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apac= he/http/impl/conn/AbstractClientConnAdapter.java (original) >> =A0+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apac= he/http/impl/conn/AbstractClientConnAdapter.java Mon Feb 22 18:45:55 2010 >> =A0@@ -43,6 +43,7 @@ >> =A0 import org.apache.http.conn.OperatedClientConnection; >> =A0 import org.apache.http.conn.ManagedClientConnection; >> =A0 import org.apache.http.conn.ClientConnectionManager; >> =A0+import org.apache.http.protocol.HttpContext; >> >> =A0 /** >> =A0 * Abstract adapter from {@link OperatedClientConnection operated} to >> =A0@@ -65,7 +66,8 @@ >> =A0 * >> =A0 * @since 4.0 >> =A0 */ >> =A0-public abstract class AbstractClientConnAdapter implements ManagedCl= ientConnection { >> =A0+public abstract class AbstractClientConnAdapter >> =A0+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0implements M= anagedClientConnection, HttpContext { >> >> =A0 =A0 =A0/** >> =A0 =A0 =A0 * The connection manager, if any. >> =A0@@ -322,4 +324,32 @@ >> =A0 =A0 =A0 =A0 =A0} >> =A0 =A0 =A0} >> >> =A0+ =A0 =A0public synchronized Object getAttribute(final String id) { >> =A0+ =A0 =A0 =A0 =A0OperatedClientConnection conn =3D getWrappedConnecti= on(); >> =A0+ =A0 =A0 =A0 =A0assertValid(conn); >> =A0+ =A0 =A0 =A0 =A0if (conn instanceof HttpContext) { >> =A0+ =A0 =A0 =A0 =A0 =A0 =A0return ((HttpContext) conn).getAttribute(id)= ; >> =A0+ =A0 =A0 =A0 =A0} else { >> =A0+ =A0 =A0 =A0 =A0 =A0 =A0return null; >> =A0+ =A0 =A0 =A0 =A0} >> =A0+ =A0 =A0} >> =A0+ >> =A0+ =A0 =A0public synchronized Object removeAttribute(final String id) = { >> =A0+ =A0 =A0 =A0 =A0OperatedClientConnection conn =3D getWrappedConnecti= on(); >> =A0+ =A0 =A0 =A0 =A0assertValid(conn); >> =A0+ =A0 =A0 =A0 =A0if (conn instanceof HttpContext) { >> =A0+ =A0 =A0 =A0 =A0 =A0 =A0return ((HttpContext) conn).removeAttribute(= id); >> =A0+ =A0 =A0 =A0 =A0} else { >> =A0+ =A0 =A0 =A0 =A0 =A0 =A0return null; >> =A0+ =A0 =A0 =A0 =A0} >> =A0+ =A0 =A0} >> =A0+ >> =A0+ =A0 =A0public synchronized void setAttribute(final String id, final= Object obj) { >> =A0+ =A0 =A0 =A0 =A0OperatedClientConnection conn =3D getWrappedConnecti= on(); >> =A0+ =A0 =A0 =A0 =A0assertValid(conn); >> =A0+ =A0 =A0 =A0 =A0if (conn instanceof HttpContext) { >> =A0+ =A0 =A0 =A0 =A0 =A0 =A0((HttpContext) conn).setAttribute(id, obj); >> =A0+ =A0 =A0 =A0 =A0} >> =A0+ =A0 =A0} >> =A0+ >> =A0 } >> >> =A0Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/or= g/apache/http/impl/conn/DefaultClientConnection.java >> =A0URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/htt= pclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.jav= a?rev=3D915013&r1=3D915012&r2=3D915013&view=3Ddiff >> =A0=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D >> =A0--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apac= he/http/impl/conn/DefaultClientConnection.java (original) >> =A0+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apac= he/http/impl/conn/DefaultClientConnection.java Mon Feb 22 18:45:55 2010 >> =A0@@ -29,6 +29,8 @@ >> >> =A0 import java.io.IOException; >> =A0 import java.net.Socket; >> =A0+import java.util.HashMap; >> =A0+import java.util.Map; >> >> =A0 import org.apache.http.annotation.NotThreadSafe; >> >> =A0@@ -41,6 +43,7 @@ >> =A0 import org.apache.http.HttpResponse; >> =A0 import org.apache.http.HttpResponseFactory; >> =A0 import org.apache.http.params.HttpParams; >> =A0+import org.apache.http.protocol.HttpContext; >> =A0 import org.apache.http.impl.SocketHttpClientConnection; >> =A0 import org.apache.http.io.HttpMessageParser; >> =A0 import org.apache.http.io.SessionInputBuffer; >> =A0@@ -65,7 +68,7 @@ >> =A0 */ >> =A0 @NotThreadSafe // connSecure, targetHost >> =A0 public class DefaultClientConnection extends SocketHttpClientConnect= ion >> =A0- =A0 =A0implements OperatedClientConnection { >> =A0+ =A0 =A0implements OperatedClientConnection, HttpContext { >> >> =A0 =A0 =A0private final Log log =3D LogFactory.getLog(getClass()); >> =A0 =A0 =A0private final Log headerLog =3D LogFactory.getLog("org.apache= .http.headers"); >> =A0@@ -83,8 +86,12 @@ >> =A0 =A0 =A0/** True if this connection was shutdown. */ >> =A0 =A0 =A0private volatile boolean shutdown; >> >> =A0+ =A0 =A0/** connection specific attributes */ >> =A0+ =A0 =A0private final Map attributes; >> =A0+ >> =A0 =A0 =A0public DefaultClientConnection() { >> =A0 =A0 =A0 =A0 =A0super(); >> =A0+ =A0 =A0 =A0 =A0this.attributes =3D new HashMap(); > > Maybe we could use ConcurrentHashMap here? > In which case, perhaps the synchronisation could be removed from some > of the new methods. > >> =A0 =A0 =A0} >> >> =A0 =A0 =A0public final HttpHost getTargetHost() { >> =A0@@ -253,4 +260,16 @@ >> =A0 =A0 =A0 =A0 =A0} >> =A0 =A0 =A0} >> >> =A0+ =A0 =A0public Object getAttribute(final String id) { >> =A0+ =A0 =A0 =A0 =A0return this.attributes.get(id); >> =A0+ =A0 =A0} >> =A0+ >> =A0+ =A0 =A0public Object removeAttribute(final String id) { >> =A0+ =A0 =A0 =A0 =A0return this.attributes.remove(id); >> =A0+ =A0 =A0} >> =A0+ >> =A0+ =A0 =A0public void setAttribute(final String id, final Object obj) = { >> =A0+ =A0 =A0 =A0 =A0this.attributes.put(id, obj); >> =A0+ =A0 =A0} >> =A0+ >> =A0 } >> >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org > For additional commands, e-mail: dev-help@hc.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org