Return-Path: Mailing-List: contact commons-httpclient-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list commons-httpclient-dev@jakarta.apache.org Received: (qmail 7808 invoked from network); 6 May 2003 08:14:22 -0000 Received: from unknown (HELO KCCXOEX11.corp.kpmgconsulting.com) (57.80.136.23) by daedalus.apache.org with SMTP; 6 May 2003 08:14:22 -0000 Received: from kccxoex03.corp.kpmgconsulting.com ([57.80.136.6]) by KCCXOEX11.corp.kpmgconsulting.com with Microsoft SMTPSVC(5.0.2195.5329); Tue, 6 May 2003 08:12:16 +0000 X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: Why is the HttpConnectionManager a field in HttpState? Date: Tue, 6 May 2003 09:14:32 +0100 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Why is the HttpConnectionManager a field in HttpState? Thread-Index: AcMTZI2Ltk6fS5gsSc22YK/KvSNstgAQ1Jbg From: "Kalnichevski, Oleg" To: "Commons HttpClient Project" X-OriginalArrivalTime: 06 May 2003 08:12:16.0937 (UTC) FILETIME=[3530E990:01C313A7] X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Laura, In my opinion HttpConnectionManager has nothing to do with the HTTP = state information. It should not be coupled with HttpState class. I = suggest we deprecate HttpState#getHttpConnectionManager & = HttpState#setHttpConnectionManager methods Oleg -----Original Message----- From: Laura Werner [mailto:laura@lwerner.org] Sent: Tuesday, May 06, 2003 02:15 To: Commons HttpClient Project Subject: Why is the HttpConnectionManager a field in HttpState? Hi, I just discovered a sort of a gotcha with the patch I submitted on=20 Friday. Imagine code like this: HttpConnectionManager manager =3D new = MultiThreadedHttpConnectionManager(); HttpClient myClient =3D new HttpClient(manager); HttpState myState =3D new HttpState(); ... myClient.executeMethod(hostConfig, method, myState); This didn't behave the way I expected, because HttpClient.executeMethod=20 ends up calling HttpState.getHttpConnectionManager() to find the=20 connection manager to use. I had naively expected it to use the manager = that I passed in to the constructor, but that one is only used for=20 constructing the HttpClient's default HttpState object. I'm not entirely sure what to do about this. One option would be to add = another argument to my overload of executeMethod and allow the=20 connection manager to be passed in as well. If it's null, the one from=20 the HttpState would be used. This works but makes the API fairly=20 complicated semantically. Does anyone have a better idea? The way I'm working around this in the short term is by calling=20 myState.setHttpConnectionManager(manager) before each call to=20 executeMethod. But that's *really* ugly and maybe not thread-safe. =20 (Are writes atomic in Java?) Laura --------------------------------------------------------------------- To unsubscribe, e-mail: = commons-httpclient-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: = commons-httpclient-dev-help@jakarta.apache.org