Hi Oleg,

Yes, we're shutting down the client from a callback in the actual application. The design of the program is a state machine that issues requests and processes the responses. If there's a failure during the process (received via the failure() callback) we terminate the state machine and part of that process is closing the client.

We've added code, as a workaround, to spawn a temporary worker thread to close the connection. That has worked. So if there's no solution to the original problem, we have a way to get around this.

Thanks again,
Mark


On 1/27/2016 3:38 AM, Oleg Kalnichevski wrote:
On Tue, 2016-01-26 at 13:30 -0600, Mark Johnson wrote:
Hi Oleg,

Below is a program that reproduces the hang.  It might take a couple of
runs to make this happen - it depends on what thread the callback is
generated on.  If it's on the IO Dispatcher thread, we can close the
connection on that thread also and there's no problem.  If the callback
comes on the pool-thread the program hangs.  The stack trace of the
pool-thread when this happens looks like this:

Thread [pool-1-thread] (Suspended)    <--  I paused it in the debugger
but this is where it stays
    owns: SessionRequestImpl (id=44)
    waiting for: Thread (id=21)
    Object.wait(long)
     Thread.join(long)
     Thread.join()
     InternalHttpAsyncClient(ClosableHttpAsyncClientBase).close()
     Testprog$Callback.failed(Exception)
etc.
...

@Override

public void cancelled() {

Thread t = Thread.currentThread();

System.out.println(t.getName() + ": " + "Request cancelled");

try {

System.out.println(t.getName() + ": " + "Closing client connection");

_httpclient.close();

} catch (Exception ex) {

System.out.println(t.getName() + ": " + ex.getMessage());

}

_latch.countDown();

}

Good Lord! You are shutting down the client from a callback. Is there a
good reason for that?

Regardless I'll see if there is a way to avoid a deadlock here.

Thanks for the reproducer.

Oleg



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org

Reply via email to