You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Andrey P (JIRA)" <ji...@apache.org> on 2013/02/01 02:44:11 UTC

[jira] [Created] (HTTPCLIENT-1314) Deadlock in http.client.fluent.Async.ExecRunnable.run() if there is an exception in FutureCallback

Andrey P created HTTPCLIENT-1314:
------------------------------------

             Summary: Deadlock in http.client.fluent.Async.ExecRunnable.run() if there is an exception in FutureCallback
                 Key: HTTPCLIENT-1314
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1314
             Project: HttpComponents HttpClient
          Issue Type: Bug
          Components: HttpClient
    Affects Versions: 4.3 Alpha1, 4.2.3
         Environment: Windows 7 64bits
            Reporter: Andrey P


Deadlock in http.client.fluent.Async.ExecRunnable.run() if an exception is thrown in FutureCallback.completed()
Look at the <<<http.client.fluent.Async.ExecRunnable.run()>>> method:
public void run() {
            try {
                Response response = this.executor.execute(this.request);
                T result = response.handleResponse(this.handler);
                this.future.completed(result);
            } catch (Exception ex) {
**** this is never called because the BasicFuture.completed flag is set to true BEFORE the callback invocation 
**** (see  below)
                this.future.failed(ex);
            }
        }

<<<http.concurrent.BasicFuture>>>
public synchronized boolean completed(final T result) {
        if (this.completed) {
            return false;
        }
        this.completed = true;
        this.result = result;
        if (this.callback != null) {
            this.callback.completed(result);
        }
*** not executed if an exception in the callback.completed()
        notifyAll();
        return true;
    }
public synchronized boolean failed(final Exception exception) {
        if (this.completed) {
            return false;
        }
*** the following can't be reached if there is an exception in  this.callback.completed() so that 
*** BasicFuture.get() waits forever

        this.completed = true;
        this.ex = exception;
        if (this.callback != null) {
            this.callback.failed(exception);
        }
        notifyAll();
        return true;
    }


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