Hi Sam,

The SimpleHttpConnectionManager is not meant to be used by more than one thread. Threading is not explicitly mentioned, though it is implied by the JavaDocs.

From SimpleHttpConnectionManager: A connection manager that provides access to a single HttpConnection. This manager makes no attempt to provide exclusive access to the contained HttpConnection.

I will add something more definitive to the docs. For multi-threaded apps you need either the MultiThreadedHttpConnectionManager or one HttpClient instance per thread.

Mike

On Dec 21, 2003, at 3:37 PM, Sam Berlin wrote:

Hi Folks,

It seems that SimpleConnectionManager is unable to properly manage sessions over multiple threads (in rc2, atleast). Is it even supposed to? (I don't see anything in the docs that mentions yay or nay.) The problem is that SimpleConnectionManager.getConnection() calls close on the existing connection if it is open and HttpConnection throws an IllegalStateException in various places if the connection is not open. Thus, for example, one thread can enter write(byte[], int, int) and another can then call close() on it, leaving the first thread to throw an IllegalStateException when it resumes.

I imagine that there is no real pressing desire to fix this, as SimpleConnectionManager should be just that (simple). Perhaps the documentation for SimpleConnectionManager should explicitly state that it is not designed to be used across multiple threads? Should we create a new SimpleConnectionManager (or, not provide one in the constructor for HttpClient, leaving it to create its own) for each client? The only problem with this that multiple requests won't reuse the same connection.

For the stracktrace, visit: http://bugs.limewire.com/dev/exceptions/3.7.1/ java.lang.IllegalStateException/Mac%20OS/1.1.8/err51460.txt . (Note that the line numbers may be off because I've modified the source slightly to work with 1.1.8, but the spirit of the bug still exists in the unmodified source.)

Thanks,
 Sam


---------------------------------------------------------------------
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]



Reply via email to