You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Jonathan Burke (JIRA)" <ji...@apache.org> on 2012/08/30 22:35:07 UTC

[jira] [Created] (HTTPCLIENT-1229) @ThreadSafe BasicClientConnectionManager is not threadsafe with respect to shutdown

Jonathan Burke created HTTPCLIENT-1229:
------------------------------------------

             Summary: @ThreadSafe BasicClientConnectionManager is not threadsafe with respect to shutdown
                 Key: HTTPCLIENT-1229
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1229
             Project: HttpComponents HttpClient
          Issue Type: Bug
          Components: HttpConn
    Affects Versions: 4.2.1
            Reporter: Jonathan Burke
            Priority: Minor


Since the assignment to variable shutdown in the shutdown method (line 262) is not part of the synchronize block and none of the assertNotShutdown method calls are within the synchronized blocks of their enclosing methods, it is possible to have threads execute the commands of BasicClientConnectionManager methods in the following sequence.

Thread 1
releaseConnection (or some other method that uses assertNotShutdown is called)
  assertNotShutdown - Passes - Line 183

Thread 2
shutdown
  the shutdown flag becomes true - Line 262
  shutdown releases this.poolEntry and this.conn in the synchronized(this) block
  
Thread 1
  release connection's synchronized(this) block get's executed 
  	this.poolEntry is null in the try block causing a null pointer exception - Line 211
  	this.poolEntry is null in the finally block causing a null pointer exception - Line 224

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
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


[jira] [Updated] (HTTPCLIENT-1229) @ThreadSafe BasicClientConnectionManager is not threadsafe with respect to shutdown

Posted by "Jonathan Burke (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCLIENT-1229?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jonathan Burke updated HTTPCLIENT-1229:
---------------------------------------

    Attachment: test.txt

Test that will should result in a null-pointer exception (a stack trace should also be attached to this issue.)
                
> @ThreadSafe BasicClientConnectionManager is not threadsafe with respect to shutdown
> -----------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1229
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1229
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpConn
>    Affects Versions: 4.2.1
>            Reporter: Jonathan Burke
>            Priority: Minor
>         Attachments: BasicClientConnectionManager.java, stackTrace.txt, test.txt
>
>
> Since the assignment to variable shutdown in the shutdown method (line 262) is not part of the synchronize block and none of the assertNotShutdown method calls are within the synchronized blocks of their enclosing methods, it is possible to have threads execute the commands of BasicClientConnectionManager methods in the following sequence.
> Thread 1
> releaseConnection (or some other method that uses assertNotShutdown is called)
>   assertNotShutdown - Passes - Line 183
> Thread 2
> shutdown
>   the shutdown flag becomes true - Line 262
>   shutdown releases this.poolEntry and this.conn in the synchronized(this) block
>   
> Thread 1
>   release connection's synchronized(this) block get's executed 
>   	this.poolEntry is null in the try block causing a null pointer exception - Line 211
>   	this.poolEntry is null in the finally block causing a null pointer exception - Line 224

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
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


[jira] [Comment Edited] (HTTPCLIENT-1229) @ThreadSafe BasicClientConnectionManager is not threadsafe with respect to shutdown

Posted by "Jonathan Burke (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1229?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13445274#comment-13445274 ] 

Jonathan Burke edited comment on HTTPCLIENT-1229 at 8/31/12 7:38 AM:
---------------------------------------------------------------------

Test that will should result in a null-pointer exception (a stack trace should also be attached to this issue.)  I originally placed this test at the bottom of of TestBasicConnManager.java but that might be a little unreasonable since it relies on executing the test case iteratively until the thread ordering produces the undesired series of steps.
                
      was (Author: jburke42):
    Test that will should result in a null-pointer exception (a stack trace should also be attached to this issue.)
                  
> @ThreadSafe BasicClientConnectionManager is not threadsafe with respect to shutdown
> -----------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1229
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1229
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpConn
>    Affects Versions: 4.2.1
>            Reporter: Jonathan Burke
>            Priority: Minor
>         Attachments: BasicClientConnectionManager.java, stackTrace.txt, test.txt
>
>
> Since the assignment to variable shutdown in the shutdown method (line 262) is not part of the synchronize block and none of the assertNotShutdown method calls are within the synchronized blocks of their enclosing methods, it is possible to have threads execute the commands of BasicClientConnectionManager methods in the following sequence.
> Thread 1
> releaseConnection (or some other method that uses assertNotShutdown is called)
>   assertNotShutdown - Passes - Line 183
> Thread 2
> shutdown
>   the shutdown flag becomes true - Line 262
>   shutdown releases this.poolEntry and this.conn in the synchronized(this) block
>   
> Thread 1
>   release connection's synchronized(this) block get's executed 
>   	this.poolEntry is null in the try block causing a null pointer exception - Line 211
>   	this.poolEntry is null in the finally block causing a null pointer exception - Line 224

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
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


[jira] [Updated] (HTTPCLIENT-1229) @ThreadSafe BasicClientConnectionManager is not threadsafe with respect to shutdown

Posted by "Jonathan Burke (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCLIENT-1229?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jonathan Burke updated HTTPCLIENT-1229:
---------------------------------------

    Attachment: stackTrace.txt

A stack trace generated by the attached test.
                
> @ThreadSafe BasicClientConnectionManager is not threadsafe with respect to shutdown
> -----------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1229
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1229
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpConn
>    Affects Versions: 4.2.1
>            Reporter: Jonathan Burke
>            Priority: Minor
>         Attachments: BasicClientConnectionManager.java, stackTrace.txt, test.txt
>
>
> Since the assignment to variable shutdown in the shutdown method (line 262) is not part of the synchronize block and none of the assertNotShutdown method calls are within the synchronized blocks of their enclosing methods, it is possible to have threads execute the commands of BasicClientConnectionManager methods in the following sequence.
> Thread 1
> releaseConnection (or some other method that uses assertNotShutdown is called)
>   assertNotShutdown - Passes - Line 183
> Thread 2
> shutdown
>   the shutdown flag becomes true - Line 262
>   shutdown releases this.poolEntry and this.conn in the synchronized(this) block
>   
> Thread 1
>   release connection's synchronized(this) block get's executed 
>   	this.poolEntry is null in the try block causing a null pointer exception - Line 211
>   	this.poolEntry is null in the finally block causing a null pointer exception - Line 224

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
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


[jira] [Resolved] (HTTPCLIENT-1229) @ThreadSafe BasicClientConnectionManager is not threadsafe with respect to shutdown

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCLIENT-1229?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski resolved HTTPCLIENT-1229.
-------------------------------------------

    Resolution: Fixed

This turned out to be more of an internal state management issue than a synchronization bug. I committed a fix for this defect to SVN trunk and 4.2.x branch.

Oleg
                
> @ThreadSafe BasicClientConnectionManager is not threadsafe with respect to shutdown
> -----------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1229
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1229
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpConn
>    Affects Versions: 4.2.1
>            Reporter: Jonathan Burke
>            Priority: Minor
>         Attachments: BasicClientConnectionManager.java, stackTrace.txt, test.txt
>
>
> Since the assignment to variable shutdown in the shutdown method (line 262) is not part of the synchronize block and none of the assertNotShutdown method calls are within the synchronized blocks of their enclosing methods, it is possible to have threads execute the commands of BasicClientConnectionManager methods in the following sequence.
> Thread 1
> releaseConnection (or some other method that uses assertNotShutdown is called)
>   assertNotShutdown - Passes - Line 183
> Thread 2
> shutdown
>   the shutdown flag becomes true - Line 262
>   shutdown releases this.poolEntry and this.conn in the synchronized(this) block
>   
> Thread 1
>   release connection's synchronized(this) block get's executed 
>   	this.poolEntry is null in the try block causing a null pointer exception - Line 211
>   	this.poolEntry is null in the finally block causing a null pointer exception - Line 224

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
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


[jira] [Updated] (HTTPCLIENT-1229) @ThreadSafe BasicClientConnectionManager is not threadsafe with respect to shutdown

Posted by "Jonathan Burke (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCLIENT-1229?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jonathan Burke updated HTTPCLIENT-1229:
---------------------------------------

    Attachment: BasicClientConnectionManager.java

A potential fix that involves extending the synchronized blocks to encompass assigning to shutdown and assertNotShtudown statements.
                
> @ThreadSafe BasicClientConnectionManager is not threadsafe with respect to shutdown
> -----------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1229
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1229
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpConn
>    Affects Versions: 4.2.1
>            Reporter: Jonathan Burke
>            Priority: Minor
>         Attachments: BasicClientConnectionManager.java, stackTrace.txt, test.txt
>
>
> Since the assignment to variable shutdown in the shutdown method (line 262) is not part of the synchronize block and none of the assertNotShutdown method calls are within the synchronized blocks of their enclosing methods, it is possible to have threads execute the commands of BasicClientConnectionManager methods in the following sequence.
> Thread 1
> releaseConnection (or some other method that uses assertNotShutdown is called)
>   assertNotShutdown - Passes - Line 183
> Thread 2
> shutdown
>   the shutdown flag becomes true - Line 262
>   shutdown releases this.poolEntry and this.conn in the synchronized(this) block
>   
> Thread 1
>   release connection's synchronized(this) block get's executed 
>   	this.poolEntry is null in the try block causing a null pointer exception - Line 211
>   	this.poolEntry is null in the finally block causing a null pointer exception - Line 224

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
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