Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] how to shut down jetty httpclient (version 9.1)

Your code example attempts to stop the client from within a client thread.
Don't do that.

client.stop() should be called from outside of the client threads.

Typically, you start 1 HttpClient for the lifetime of the application, then just continue to reuse it for multiple requests / connections. only stopping it when your application is being shutdown.

Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts

On Tue, Nov 26, 2013 at 3:54 AM, Kiwi de coder <kiwionly@xxxxxxxxx> wrote:
I had run the test again, now the client.stop is working for code above. (not sure what wrong previously, maybe my mistake). However, code for async :

                final HttpClient client = new HttpClient();
client.newRequest("").send(new BufferingResponseListener() {
public void onComplete(Result result) {
try {
} catch (Exception e) {
// TODO Auto-generated catch block

look like when called client.stop(), it show this exception after a while (few seconds), to terminate the thread.

2013-11-26 18:46:26.688:WARN:oejuc.AbstractLifeCycle:HttpClient@1998356146-10: FAILED HttpClient@1998356146{FAILED,8<=1<=200,i=0,q=0}: java.lang.InterruptedException
at java.lang.Object.wait(Native Method)
at java.lang.Thread.join(Unknown Source)
at org.eclipse.jetty.util.thread.QueuedThreadPool.doStop(
at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(
at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(
at org.eclipse.jetty.client.HttpClient.doStop(
at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(
at com.http.HttpClientTest$1.onComplete(
at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(
at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(
at org.eclipse.jetty.client.HttpReceiver.responseSuccess(
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.messageComplete(
at org.eclipse.jetty.http.HttpParser.parseContent(
at org.eclipse.jetty.http.HttpParser.parseNext(
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.parse(
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.receive(
at org.eclipse.jetty.client.http.HttpChannelOverHTTP.receive(
at org.eclipse.jetty.client.http.HttpConnectionOverHTTP.onFillable(
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(
at org.eclipse.jetty.util.thread.QueuedThreadPool$
at Source)

not sure is this correct way to close async call ?


jetty-users mailing list

Back to the top