You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Ivàn Silva (JIRA)" <ji...@apache.org> on 2011/07/21 21:52:59 UTC

[jira] [Commented] (HTTPCLIENT-633) MultiThreadedHttpConnectionManager does not properly respond to thread interrupts

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-633?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13069161#comment-13069161 ] 

Ivàn Silva commented on HTTPCLIENT-633:
---------------------------------------

Hi group, I need to know what problem Can I have with this extract
org/apache/commons/httpclient/MultiThreadedHttpConnectionManager$Connect
ionPool@0x00000000408C3638/0x00000000408C3644: <unowned>                
Waiting to be notified:                                                 
   "WebContainer : 0" (0x0000000031B71C00)                              
   "WebContainer : 1" (0x0000000031AE6700)                              
   "WebContainer : 2" (0x0000000031E22900)                              
   "WebContainer : 3" (0x000000003202AF00)                              
   "WebContainer : 5" (0x0000000031CCDB00)                              
   "WebContainer : 6" (0x0000000032294B00)                              
     ..................                                                 
     "WebContainer : 55" (0x0000000032620000)                           
     "WebContainer : 56" (0x000000003266F200)                           
     "WebContainer : 58" (0x000000003267CE00)                           
     "WebContainer : 59" (0x000000003267DE00)                           
                                                                        
"WebContainer : 0" J9VMThread:0x0000000031B71C00,                       
j9thread_t:0x000000011A85AD40,                                          
java/lang/Object.wait(Native Method)                                    
                                                                        
java/lang/Object.wait(Object.java:196(Compiled Code))                   
org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.doGetConnectin                                                                 
org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.getConn
org/apache/commons/httpclient/HttpMethodDirector.executeMethod(HttpMetho
org/apache/commons/httpclient/HttpClient.executeMethod(HttpClient.java:3
org/apache/commons/httpclient/HttpClient.executeMethod(HttpClient.java:3
com/citibank/latam/sgway/service/HttpConnectorImpl.doPost(HttpConnectorI
com/citibank/latam/sgway/service/HttpConnectorImpl.doPost(HttpConnectorI
com/citibank/latam/sgway/service/LegacySgConnector.doPost(LegacySgConnec
com/citibank/latam/sgway/service/LegacySgConnector.authenticateFull(Lega
com/citi/acam/session/impl/SGTokenGenerator.getToken(SGTokenGenerator.ja
com/citi/acam/session/ACAMCredential.<init>(ACAMCredential.java:24(Compi
com/citi/common/transaction/web/CtrlLogin.actionSetLogin(CtrlLogin.java:
com/citi/common/transaction/web/CtrlLogin.doPost(CtrlLogin.java:67(Compi

Can you help me please? Can be MultiThreadedHttpConnectionManager don't properly respond to thread interrupts?


> MultiThreadedHttpConnectionManager does not properly respond to thread interrupts
> ---------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-633
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-633
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>    Affects Versions: 3.1 Beta 1
>            Reporter: John Goodwin
>            Assignee: Michael Becke
>             Fix For: 3.1 RC1
>
>         Attachments: mthcm-interruption.patch, mthcm-interruption.patch
>
>
> MultiThreadedHttpConnectionManager uses interrupts to notify waiting threads when a connection is ready for them. Issues arise if the threads are interrupted by someone else while they are still waiting on a thread, because doGetConnection does not remove the threads from the queue of waiting threads when they are interrupted:
>                         connectionPool.wait(timeToWait);
>                         // we have not been interrupted so we need to remove ourselves from the 
>                         // wait queue
>                         hostPool.waitingThreads.remove(waitingThread);                        connectionPool.waitingThreads.remove(waitingThread);
>                     } catch (InterruptedException e) {
>                         // do nothing                    } finally {
>                         if (useTimeout) {
>                             endWait = System.currentTimeMillis();
>                             timeToWait -= (endWait - startWait);                        }                    }
> Under ordinary circumstances, the queue maintenance is done by the notifyWaitingThread method. However, if the thread is interrupted by any other part of the system, it will (1) not actually be released, since the loop in doGetConnection will force it back to the wait, and (2) will be added the waiting thread to the queue repeatedly, which basically means that the thread will eventually receive the interrupt from notifyWaitingThread at some later point, when it is no longer actually waiting for a connection.
> This code could probably be re-architected to make it less error-prone, but the fundamental issue seems to be the use of interrupts to signal waiting threads, as opposed to something like a notify. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

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