Re: Deadlock problem with MultiThreadedHttpConnectionManager

2003-06-18 Thread Eric Johnson
Ortwin,

It is an odd problem.  Not quite a dead-lock in the traditional sense.  
One thread is waiting on the other, and the other is waiting for the 
garbage collector.  It just so happens that the garbage collector will 
never kick in, because the first thread happens to be the AWT Event 
thread, so the user cannot interact with the application any further, 
thus no objects get allocated, and there is no reason to garbage 
collect. To oversimplify, Thread A depends on Thread B depends on Thread 
C depends (indirectly) on Thread A.

Ortwin Glück wrote:

It's not clear to me how this can be a dead lock.

Eric Johnson wrote:

MultiThreadedHttpConnectionManager.doGetConnection() - line 302, 
which reads connectionPool.wait(timeToWait),


This is a limited wait. Not infinite. Oleg, do we ensure that 
timeToWait0 somehow?
You seem to be echoing one of my recommendations - the code should 
disallow passing zero here.  It doesn't currently, but I think it 
should, since the timeout value it is using is the one associated 
internally with socket connection timeouts, which if not set essentially 
defaults to the lower bound of what all the intervening routers allow, 
whereas this particular wait has no limit besides what we pass.


and the other thread at

MultiThreadedHttpConnectionManager.ReferenceQueuedThread.run(), line 
665, which reads Reference ref = referenceQueue.remove();.


Both lines of code are in a block synchronized on the same object 
(connectionPool). So how can happen what you observe? Two different 
threads both in a synchronized block on the same object?

-
To unsubscribe, e-mail: 
[EMAIL PROTECTED]
For additional commands, e-mail: 
[EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Deadlock problem with MultiThreadedHttpConnectionManager

2003-06-18 Thread Ortwin Glück
Michael Becke wrote:
We allow a 0 timeout indicating an infinite wait.  This is in fact the 
default.
Makes me think of Queen's song who wants to live forever :-)

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Commas in Cookie Value

2003-06-18 Thread Ron Tower
Hello All,

Is there a problem when  a comma appears in a cookie value? See 02109POS below. It has 
a comma in the value and is split into two cookies. IE at least parses this cookie as 
one cookie. Is there a workaround for this?

My understanding is that a cookie value can have any character other than a semicolon, 
space, or tab.

I got the following Set-Cookie headers:

[DEBUG] wire - - Set-cookie: CDSContentDistributor=137169; expires=Tuesday, 
17-Jun-03 20:52:01 GMT; path=/[\r][\n]
[DEBUG] wire - - Set-cookie: 02109POS=www4210513143792642538,; 
domain=.fidelity.com; path=/; expires=Fri, 12-Sep-2003 00:00:00 GMT;[\r][\n]
[DEBUG] wire - - Set-cookie: 
MC=clHza1XIKW50aXo3nr5LD3gDFYMSAiWYtqihBBHXpfPA37wNqncGBQAGBT7vfRkAP03; 
expires=Monday, 15-Sep-2003 20:42:01 GMT; domain=.fidelity.com; path=/[\r][\n]

And HttpClient sent the following Cookies:

[DEBUG] wire - - Cookie: $Version=0; CDSContentDistributor=137169; $Path=/[\r][\n]
[DEBUG] wire - - Cookie: $Version=0; 02109POS=www4210513143792642538[\r][\n]
[DEBUG] wire - - Cookie: $Version=0; =; $Domain=.fidelity.com; $Path=/[\r][\n]
[DEBUG] wire - - Cookie: $Version=0; 
MC=clHza1XIKW50aXo3nr5LD3gDFYMSAiWYtqihBBHXpfPA37wNqncGBQAGBT7vfRkAP03; 
$Domain=.fidelity.com; $Path=/[\r][\n]

Thanks,

Ron Tower


Re: Deadlock problem with MultiThreadedHttpConnectionManager

2003-06-18 Thread Eric Johnson
Mike,

I think you're roughly agreeing with what I would conclude, but I wasn't 
sure and I wanted to get other's feedback.

Michael Becke wrote:

Doing something time-consuming from the event thread is a little 
questionable I think.  It's an easy way to keep a user from using the 
UI but it causes problems like this.  I would suggest executing the 
HttpClient call from another thread and popping up a modal dialog.  
This way the UI is still responsive and you can add a cancel button to 
stop the HttpClient method if you like.
Unfortunately, I am not directly responsible for the design and 
implementation of the product, and we're not focusing resources 
elsewhere, so dramatic changes like the ones you suggest are not 
possible.  I agree with your point, though, and would change it if I could!


This leads me to ask two questions:
Should we add a call to System.gc() at line 302 of 
MultiThreadedHttpConnectionManager?


The support for detecting GCed connections is a last resort.  In 
general it should never be relied on and was mostly just added as a 
cool feature.

Doing explicit GCs from within the HttpClient code is definitely a 
hack.  It can be quite time consuing and there is no guarantee that it 
will have any effect.  You could certainly add a GC in your code but I 
think it is not something we want to include in HttpClient.
Yeah, I was leaning that way too, in that the gc() call is a hack.


Should we ever invoke the connectionPool.wait() with a zero value, 
or should this always time out?  I think this would be better if it 
always timed out, as it is possible, as my scenario shows, to get 
into states where the garbage collector never runs, the connections 
are never freed, and the application grinds to a halt.


Having a zero value is quite valid I think.  There are some cases when 
you want to wait until a connection is available regardless of how 
long that takes.  Though 0 is the default value it can certainly be 
set in your application.  Having the thread timeout doesn't really 
solve your problem though.  It just lets you know you have a problem.
Letting me know I had a problem would be better than what the 
application does now!  In my case, it would solve the problem to the 
extent that the program would not appear to be frozen.

The price of using the MultiThreadedHttpConnectionManager is that 
connections must be released manually.  It trades off the benefit of 
connection reuse/management for the burden of connection release.

I think the only real solution in this case is to ensure that 
connections are released manually.

Also, I am wondering if all of this is happening in the UI thread why 
are you using the MultiThreadedHttpConnectionManager?  It is really 
for sharing/reusing connections among various threads.
Of course, there are a variety of reasons for using 
MultiThreadedHttpConnectionManager, if only because the other option is, 
well, too simple.  We do have other threads, they just don't happen to 
get kicked off in the problematic scenario.

Thanks for the feedback.

-Eric.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Deadlock problem with MultiThreadedHttpConnectionManager

2003-06-18 Thread Michael Becke
Karaoke at Ortwin's house tonight :)

Mike

Ortwin Glück wrote:
Michael Becke wrote:

We allow a 0 timeout indicating an infinite wait.  This is in fact the 
default.


Makes me think of Queen's song who wants to live forever :-)

-
To unsubscribe, e-mail: 
[EMAIL PROTECTED]
For additional commands, e-mail: 
[EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Deadlock problem with MultiThreadedHttpConnectionManager

2003-06-18 Thread Michael Becke
Eric,

I think you're roughly agreeing with what I would conclude, but I wasn't 
sure and I wanted to get other's feedback.
Yes, I think your analysis was correct.

Unfortunately, I am not directly responsible for the design and 
implementation of the product, and we're not focusing resources 
elsewhere, so dramatic changes like the ones you suggest are not 
possible.  I agree with your point, though, and would change it if I could!
Darn that real world:)

Good luck.

Mike

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Commas in Cookie Value

2003-06-18 Thread Ron Tower
Brett,

I didn't download the source, just the jar and the docs. Could I subclass
from a CookieSpec and just replace the parse of Set-Cookie? I would prefer
to not have to modify the source so I can easily replace it with upcoming
versions without having to put my change back in.

Is your fix going into the main source? Do you know when?

But if there is no other way, I can download the source, and then I would
appreciate your fix.

Thanks,

Ron Tower

- Original Message -
From: Brett Knights [EMAIL PROTECTED]
To: Commons HttpClient Project [EMAIL PROTECTED]
Sent: Wednesday, June 18, 2003 3:06 PM
Subject: Re: Commas in Cookie Value


 I have a fix for this but it uses the org.apache.oro regular
 expression parser.
 E-mail me off line if you want the code to hack your own copy of
 HttpClient

 - Original Message -
 From: Ron Tower [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Wednesday, June 18, 2003 9:26 AM
 Subject: Commas in Cookie Value


 Hello All,

 Is there a problem when  a comma appears in a cookie value? See
 02109POS below. It has a comma in the value and is split into two
 cookies. IE at least parses this cookie as one cookie. Is there a
 workaround for this?

 My understanding is that a cookie value can have any character other
 than a semicolon, space, or tab.

 I got the following Set-Cookie headers:

 [DEBUG] wire - - Set-cookie: CDSContentDistributor=137169;
 expires=Tuesday, 17-Jun-03 20:52:01 GMT; path=/[\r][\n]
 [DEBUG] wire - - Set-cookie: 02109POS=www4210513143792642538,;
 domain=.fidelity.com; path=/; expires=Fri, 12-Sep-2003 00:00:00
 GMT;[\r][\n]
 [DEBUG] wire - - Set-cookie:
 MC=clHza1XIKW50aXo3nr5LD3gDFYMSAiWYtqihBBHXpfPA37wNqncGBQAGBT7vfRk
 AP03; expires=Monday, 15-Sep-2003 20:42:01 GMT; domain=.fidelity.com;
 path=/[\r][\n]

 And HttpClient sent the following Cookies:

 [DEBUG] wire - - Cookie: $Version=0; CDSContentDistributor=137169;
 $Path=/[\r][\n]
 [DEBUG] wire - - Cookie: $Version=0;
 02109POS=www4210513143792642538[\r][\n]
 [DEBUG] wire - - Cookie: $Version=0; =; $Domain=.fidelity.com;
 $Path=/[\r][\n]
 [DEBUG] wire - - Cookie: $Version=0;
 MC=clHza1XIKW50aXo3nr5LD3gDFYMSAiWYtqihBBHXpfPA37wNqncGBQAGBT7vfRk
 AP03; $Domain=.fidelity.com; $Path=/[\r][\n]

 Thanks,

 Ron Tower



 -
 To unsubscribe, e-mail:
[EMAIL PROTECTED]
 For additional commands, e-mail:
[EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Commas in Cookie Value

2003-06-18 Thread Oleg Kalnichevski
Rob,
This is a well known issue. According to the RFC 2109 comma is
considered a spacial character. Cookie values that contain special
characters MUST be in a quoted string. Please refer to the following bug
report for more details:

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11240

The cookie below clearly violates the RFC 2109 spec, hence the parsing
problem. 

Unfortunately, so called mainstream browsers have fairly lousy standards
compliance record when it comes to cookies. IE as well Mozilla do accept
cookie values with special characters in an unquoted string. The problem
is that our compatibility cookie policy does not mimic such behaviour as
yet. That will change in 2.1 release. So, stay tuned.

Cheers

Oleg


On Wed, 2003-06-18 at 18:26, Ron Tower wrote:
 Hello All,
 
 Is there a problem when  a comma appears in a cookie value? See 02109POS below. It 
 has a comma in the value and is split into two cookies. IE at least parses this 
 cookie as one cookie. Is there a workaround for this?
 
 My understanding is that a cookie value can have any character other than a 
 semicolon, space, or tab.
 
 I got the following Set-Cookie headers:
 
 [DEBUG] wire - - Set-cookie: CDSContentDistributor=137169; expires=Tuesday, 
 17-Jun-03 20:52:01 GMT; path=/[\r][\n]
 [DEBUG] wire - - Set-cookie: 02109POS=www4210513143792642538,; 
 domain=.fidelity.com; path=/; expires=Fri, 12-Sep-2003 00:00:00 GMT;[\r][\n]
 [DEBUG] wire - - Set-cookie: 
 MC=clHza1XIKW50aXo3nr5LD3gDFYMSAiWYtqihBBHXpfPA37wNqncGBQAGBT7vfRkAP03; 
 expires=Monday, 15-Sep-2003 20:42:01 GMT; domain=.fidelity.com; path=/[\r][\n]
 
 And HttpClient sent the following Cookies:
 
 [DEBUG] wire - - Cookie: $Version=0; CDSContentDistributor=137169; 
 $Path=/[\r][\n]
 [DEBUG] wire - - Cookie: $Version=0; 02109POS=www4210513143792642538[\r][\n]
 [DEBUG] wire - - Cookie: $Version=0; =; $Domain=.fidelity.com; $Path=/[\r][\n]
 [DEBUG] wire - - Cookie: $Version=0; 
 MC=clHza1XIKW50aXo3nr5LD3gDFYMSAiWYtqihBBHXpfPA37wNqncGBQAGBT7vfRkAP03; 
 $Domain=.fidelity.com; $Path=/[\r][\n]
 
 Thanks,
 
 Ron Tower


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Commas in Cookie Value

2003-06-18 Thread Oleg Kalnichevski
Ron (I apologise for misspelling your name in my previous post),

You can easily subclass any of the CookieSpec classes. The trouble is
there's no way to plug a custom cookie spec into the existing
implementation of HttpClient. At the moment you have to modify
CookiePolicy class and recompile Httpclient in order to get it done. We
are aware of the problem and will address it in 2.1 release.

Oleg

PS: Brett's patch may eventually make it into the official Httpclient
source tree, but that is not going to happen too soon. Maybe in 3.0



On Wed, 2003-06-18 at 22:06, Ron Tower wrote:
 Brett,
 
 I didn't download the source, just the jar and the docs. Could I subclass
 from a CookieSpec and just replace the parse of Set-Cookie? I would prefer
 to not have to modify the source so I can easily replace it with upcoming
 versions without having to put my change back in.
 
 Is your fix going into the main source? Do you know when?
 
 But if there is no other way, I can download the source, and then I would
 appreciate your fix.
 
 Thanks,
 
 Ron Tower
 
 - Original Message -
 From: Brett Knights [EMAIL PROTECTED]
 To: Commons HttpClient Project [EMAIL PROTECTED]
 Sent: Wednesday, June 18, 2003 3:06 PM
 Subject: Re: Commas in Cookie Value
 
 
  I have a fix for this but it uses the org.apache.oro regular
  expression parser.
  E-mail me off line if you want the code to hack your own copy of
  HttpClient
 
  - Original Message -
  From: Ron Tower [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Wednesday, June 18, 2003 9:26 AM
  Subject: Commas in Cookie Value
 
 
  Hello All,
 
  Is there a problem when  a comma appears in a cookie value? See
  02109POS below. It has a comma in the value and is split into two
  cookies. IE at least parses this cookie as one cookie. Is there a
  workaround for this?
 
  My understanding is that a cookie value can have any character other
  than a semicolon, space, or tab.
 
  I got the following Set-Cookie headers:
 
  [DEBUG] wire - - Set-cookie: CDSContentDistributor=137169;
  expires=Tuesday, 17-Jun-03 20:52:01 GMT; path=/[\r][\n]
  [DEBUG] wire - - Set-cookie: 02109POS=www4210513143792642538,;
  domain=.fidelity.com; path=/; expires=Fri, 12-Sep-2003 00:00:00
  GMT;[\r][\n]
  [DEBUG] wire - - Set-cookie:
  MC=clHza1XIKW50aXo3nr5LD3gDFYMSAiWYtqihBBHXpfPA37wNqncGBQAGBT7vfRk
  AP03; expires=Monday, 15-Sep-2003 20:42:01 GMT; domain=.fidelity.com;
  path=/[\r][\n]
 
  And HttpClient sent the following Cookies:
 
  [DEBUG] wire - - Cookie: $Version=0; CDSContentDistributor=137169;
  $Path=/[\r][\n]
  [DEBUG] wire - - Cookie: $Version=0;
  02109POS=www4210513143792642538[\r][\n]
  [DEBUG] wire - - Cookie: $Version=0; =; $Domain=.fidelity.com;
  $Path=/[\r][\n]
  [DEBUG] wire - - Cookie: $Version=0;
  MC=clHza1XIKW50aXo3nr5LD3gDFYMSAiWYtqihBBHXpfPA37wNqncGBQAGBT7vfRk
  AP03; $Domain=.fidelity.com; $Path=/[\r][\n]
 
  Thanks,
 
  Ron Tower
 
 
 
  -
  To unsubscribe, e-mail:
 [EMAIL PROTECTED]
  For additional commands, e-mail:
 [EMAIL PROTECTED]
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



PATCH org.apache.commons.httpclient.methods.multipart.FilePart

2003-06-18 Thread Eric M Devlin
Hey,
  This is a patch which will determine the content type if null based on
file extension.  I used the file extension mapping from
$TOMCAT_HOME/conf/web.xml.  As a side note, I'm having trouble sending gif
files.  Any thoughts or a kick in the right direction would be helpful.
Thanks and Hope It Helps
Eric
--- FilePart.java.orig  2003-06-18 22:18:41.0 -0400
+++ FilePart.java   2003-06-18 22:01:49.0 -0400
@@ -1,5 +1,5 @@
 /*
- * $Header: 
/home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/multipart/FilePart.java,v
 1.14 2003/03/16 12:05:03 olegk Exp $
+ * $Header: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/multipart/FilePart.java,v
 1.14 2003/03/16 12:05:03 olegk Exp $
  * $Revision: 1.14 $
  * $Date: 2003/03/16 12:05:03 $
  *
@@ -121,6 +121,141 @@
 /** Content encoding of the file part. */
 private String charset;
 
+   /** Mime Type mappings 'liberated' from Tomcat4.1.18/conf/web.xml*/
+   public static final String[][] MIME_TYPE_MAPPINGS = 
+   {   { abs,audio/x-mpeg },
+   { ai, application/postscript },
+   { aif,audio/x-aiff },
+   { aifc,   audio/x-aiff },
+   { aiff,   audio/x-aiff },
+   { aim,application/x-aim },
+   { art,image/x-jg },
+   { asf,video/x-ms-asf },
+   { asx,video/x-ms-asf },
+   { au, audio/basic },
+   { avi,video/x-msvideo },
+   { avx,video/x-rad-screenplay },
+   { bcpio,  application/x-bcpio },
+   { bin,application/octet-stream },
+   { bmp,image/bmp },
+   { body,   text/html },
+   { cdf,application/x-cdf },
+   { cer,application/x-x509-ca-cert },
+   { class,  application/java },
+   { cpio,   application/x-cpio },
+   { csh,application/x-csh },
+   { css,text/css },
+   { dib,image/bmp },
+   { doc,application/msword },
+   { dtd,text/plain },
+   { dv, video/x-dv },
+   { dvi,application/x-dvi },
+   { eps,application/postscript },
+   { etx,text/x-setext },
+   { exe,application/octet-stream },
+   { gif,image/gif },
+   { gtar,   application/x-gtar },
+   { gz, application/x-gzip },
+   { hdf,application/x-hdf },
+   { hqx,application/mac-binhex40 },
+   { htc,text/x-component },
+   { htm,text/html },
+   { html,   text/html },
+   { hqx,application/mac-binhex40 },
+   { ief,image/ief },
+   { jad,text/vnd.sun.j2me.app-descriptor },
+   { jar,application/java-archive },
+   { java,   text/plain },
+   { jnlp,   application/x-java-jnlp-file },
+   { jpe,image/jpeg },
+   { jpeg,   image/jpeg },
+   { jpg,image/jpeg },
+   { js, text/javascript },
+   { jsf,text/plain },
+   { jspf,   text/plain },
+   { kar,audio/x-midi },
+   { latex,  application/x-latex },
+   { m3u,audio/x-mpegurl },
+   { mac,image/x-macpaint },
+   { man,application/x-troff-man },
+   { me, application/x-troff-me },
+   { mid,audio/x-midi },
+   { midi,   audio/x-midi },
+   { mif,application/x-mif },
+   { mov,