Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimone Bordet2016-02-05 12:12:13 -0500
committerSimone Bordet2016-02-05 12:12:37 -0500
commit4a7fae30fbecfedf49200f2c2b6c644aea2df7b0 (patch)
tree31cfe9c4b48c0cd96d469a19765afe9d46098248
parent98cd85287c4d994b6b8acbe496b331bf85699966 (diff)
downloadorg.eclipse.jetty.project-4a7fae30fbecfedf49200f2c2b6c644aea2df7b0.tar.gz
org.eclipse.jetty.project-4a7fae30fbecfedf49200f2c2b6c644aea2df7b0.tar.xz
org.eclipse.jetty.project-4a7fae30fbecfedf49200f2c2b6c644aea2df7b0.zip
486829 - Cancel stream error after a failed request with the HTTP/2.0 client.
Fixed by properly notifying the callback even when the exchange has already been aborted.
-rw-r--r--jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpReceiverOverHTTP2.java3
-rw-r--r--tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpClientTest.java46
2 files changed, 49 insertions, 0 deletions
diff --git a/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpReceiverOverHTTP2.java b/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpReceiverOverHTTP2.java
index 827a8740cc..51453e822a 100644
--- a/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpReceiverOverHTTP2.java
+++ b/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpReceiverOverHTTP2.java
@@ -89,7 +89,10 @@ public class HttpReceiverOverHTTP2 extends HttpReceiver implements Stream.Listen
{
HttpExchange exchange = getHttpExchange();
if (exchange == null)
+ {
+ callback.failed(new IOException("terminated"));
return;
+ }
if (responseContent(exchange, frame.getData(), callback))
{
diff --git a/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpClientTest.java b/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpClientTest.java
index c9d3a03015..415bbe3700 100644
--- a/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpClientTest.java
+++ b/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpClientTest.java
@@ -21,6 +21,7 @@ package org.eclipse.jetty.http.client;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.util.Random;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.stream.IntStream;
@@ -35,6 +36,7 @@ import org.eclipse.jetty.client.util.BytesContentProvider;
import org.eclipse.jetty.client.util.FutureResponseListener;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
+import org.eclipse.jetty.http2.FlowControlStrategy;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.junit.Assert;
@@ -239,6 +241,50 @@ public class HttpClientTest extends AbstractTest
Assert.assertEquals(chunks * chunkSize, Integer.parseInt(response.getContentAsString()));
}
+ @Test
+ public void testRequestAfterFailedRequest() throws Exception
+ {
+ int length = FlowControlStrategy.DEFAULT_WINDOW_SIZE;
+ start(new AbstractHandler()
+ {
+ @Override
+ public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
+ {
+ baseRequest.setHandled(true);
+ response.getOutputStream().write(new byte[length]);
+ }
+ });
+
+ // Make a request with a large enough response buffer.
+ org.eclipse.jetty.client.api.Request request = client.newRequest(newURI());
+ FutureResponseListener listener = new FutureResponseListener(request, length);
+ request.send(listener);
+ ContentResponse response = listener.get(5, TimeUnit.SECONDS);
+ Assert.assertEquals(response.getStatus(), 200);
+
+ // Make a request with a small response buffer, should fail.
+ try
+ {
+ request = client.newRequest(newURI());
+ listener = new FutureResponseListener(request, length / 10);
+ request.send(listener);
+ listener.get(5, TimeUnit.SECONDS);
+ Assert.fail();
+ }
+ catch (ExecutionException x)
+ {
+ // Buffering capacity exceeded.
+ x.printStackTrace();
+ }
+
+ // Verify that we can make another request.
+ request = client.newRequest(newURI());
+ listener = new FutureResponseListener(request, length);
+ request.send(listener);
+ response = listener.get(5, TimeUnit.SECONDS);
+ Assert.assertEquals(response.getStatus(), 200);
+ }
+
private void sleep(long time) throws IOException
{
try

Back to the top