[
https://issues.apache.org/jira/browse/HTTPASYNC-21?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Franck Wolff updated HTTPASYNC-21:
----------------------------------
Description:
When a server crashes in the middle of a request, the FutureCallback associated
with the request is never notified. The same issue occurs in blocking mode,
when waiting for a future.get() answer.
Here are simple steps to reproduce this issue:
Client.java:
------------------------------------
package test;
import java.util.concurrent.Future;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.concurrent.FutureCallback;
import org.apache.http.impl.nio.client.DefaultHttpAsyncClient;
public class Client {
public static void main(String[] args) throws Exception {
DefaultHttpAsyncClient httpClient = new
DefaultHttpAsyncClient();
httpClient.start();
HttpPost request = new
HttpPost("http://localhost:8080/webapp/servlet");
request.setHeader("Content-Type", "text/plain");
final Future<HttpResponse> future = httpClient.execute(request,
new FutureCallback<HttpResponse>() {
public void completed(HttpResponse response) {
System.out.println("completed: " + response);
}
public void failed(Exception e) {
e.printStackTrace();
}
public void cancelled() {
System.out.println("cancelled");
}
});
System.out.println("get: " + future.get());
httpClient.shutdown();
}
}
------------------------------------
Start a server in debug mode, with a breakpoint at the beginning of the doPost
method of the targeted servlet. Start the client and, when your breakpoint is
activated, kill the server. The client application will never end...
Maybe I'm missing something but I would have thought that the failed handler
would be called in this case and that the get() call would throw an
ExecutionException.
Thanks.
was:
When a server crash in the middle of a request, the FutureCallback associated
with the request is never notified. The same issue occurs in blocking mode,
when waiting for a future.get() answer.
Here are simple steps to reproduce this issue:
Client.java:
------------------------------------
package test;
import java.util.concurrent.Future;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.concurrent.FutureCallback;
import org.apache.http.impl.nio.client.DefaultHttpAsyncClient;
public class Client {
public static void main(String[] args) throws Exception {
DefaultHttpAsyncClient httpClient = new
DefaultHttpAsyncClient();
httpClient.start();
HttpPost request = new
HttpPost("http://localhost:8080/webapp/servlet");
request.setHeader("Content-Type", "text/plain");
final Future<HttpResponse> future = httpClient.execute(request,
new FutureCallback<HttpResponse>() {
public void completed(HttpResponse response) {
System.out.println("completed: " + response);
}
public void failed(Exception e) {
e.printStackTrace();
}
public void cancelled() {
System.out.println("cancelled");
}
});
System.out.println("get: " + future.get());
httpClient.shutdown();
}
}
------------------------------------
Start a server in debug mode, with a breakpoint at the beginning of the doPost
method of the targeted servlet. Start the client and, when your breakpoint is
activated, kill the server. The client application will never end...
Maybe I'm missing something but I would have thought that the failed handler
would be called in this case and that the get() call would throw an
ExecutionException.
Thanks.
Summary: Callback not notified when a server crashes in the middle of a
request (was: Callback not notified when a server crash in the middle of a
request)
> Callback not notified when a server crashes in the middle of a request
> ----------------------------------------------------------------------
>
> Key: HTTPASYNC-21
> URL: https://issues.apache.org/jira/browse/HTTPASYNC-21
> Project: HttpComponents HttpAsyncClient
> Issue Type: Bug
> Affects Versions: 4.0-beta1
> Environment: Mac OSX, Java 6
> Reporter: Franck Wolff
> Fix For: 4.0-beta2
>
> Attachments: CrashClient.java, CrashServlet.java, crash.war
>
>
> When a server crashes in the middle of a request, the FutureCallback
> associated with the request is never notified. The same issue occurs in
> blocking mode, when waiting for a future.get() answer.
> Here are simple steps to reproduce this issue:
> Client.java:
> ------------------------------------
> package test;
> import java.util.concurrent.Future;
> import org.apache.http.HttpResponse;
> import org.apache.http.client.methods.HttpPost;
> import org.apache.http.concurrent.FutureCallback;
> import org.apache.http.impl.nio.client.DefaultHttpAsyncClient;
> public class Client {
> public static void main(String[] args) throws Exception {
> DefaultHttpAsyncClient httpClient = new
> DefaultHttpAsyncClient();
> httpClient.start();
> HttpPost request = new
> HttpPost("http://localhost:8080/webapp/servlet");
> request.setHeader("Content-Type", "text/plain");
> final Future<HttpResponse> future = httpClient.execute(request,
> new FutureCallback<HttpResponse>() {
>
> public void completed(HttpResponse response) {
> System.out.println("completed: " + response);
> }
> public void failed(Exception e) {
> e.printStackTrace();
> }
> public void cancelled() {
> System.out.println("cancelled");
> }
> });
>
> System.out.println("get: " + future.get());
>
> httpClient.shutdown();
> }
> }
> ------------------------------------
> Start a server in debug mode, with a breakpoint at the beginning of the
> doPost method of the targeted servlet. Start the client and, when your
> breakpoint is activated, kill the server. The client application will never
> end...
> Maybe I'm missing something but I would have thought that the failed handler
> would be called in this case and that the get() call would throw an
> ExecutionException.
> Thanks.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]