hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Johnson <e...@tibco.com>
Subject Re: DO NOT REPLY [Bug 30514] New: - HttpClient deadlocks under multithreaded access
Date Sat, 07 Aug 2004 00:43:07 GMT

bugzilla@apache.org wrote:

[snip]

>    /**
>     * Keep hitting a URL, with no sleep time.
>     */
>    class ClientThread implements Runnable 
>    {
>        protected Thread m_thread;
>        protected boolean m_running = true;
>        
>        public ClientThread( )
>        {
>        }
>        
>        public void run( ) 
>        {
>            m_thread = Thread.currentThread( );
>            try 
>            {
>                while ( m_running )
>                {
>                    PostMethod httppost = new PostMethod( m_serverURL.getPath( ) );
>                    httppost.setRequestBody( "some random stuff that doesn't
>matter" );
>        
>                    try 
>                    {
>                        // print out something so we know when there are active 
>                        // threads
>                        System.out.print( "." );
>                        m_client.executeMethod( httppost );
>                    } 
>                    catch ( Throwable t )
>                    { 
>
// here you should add:
httppost.releaseConnection()

>}
>                }
>            } 
>            catch ( Throwable t )
>            {
>                t.printStackTrace( System.out );
>                m_running = false;
>            }
>        }
>    }
>}
>  
>
If you don't call releaseConnection(), HttpClient doesn't know whether 
you're done reading the response to the request, so it doesn't free up 
the connection for re-use, and the MultiThreadedConnectionManager 
eventually appears to deadlock, while it is really waiting for you to 
call releaseConnection().

-Eric.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org


Mime
View raw message