Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Erdfelt2015-03-06 17:57:52 -0500
committerJoakim Erdfelt2015-03-06 17:57:52 -0500
commit130afb95358618bd4027f206f4915ea4d6d9bfff (patch)
tree2f1b1df1ffd511a455c948d767303ef6cb70addd /jetty-servlet
parent9b5205ba40e3b605dfff96b5c9e831a419d038d2 (diff)
parentdd88d393e4aaf6b234c1dc00326941e7d34b6f92 (diff)
downloadorg.eclipse.jetty.project-130afb95358618bd4027f206f4915ea4d6d9bfff.tar.gz
org.eclipse.jetty.project-130afb95358618bd4027f206f4915ea4d6d9bfff.tar.xz
org.eclipse.jetty.project-130afb95358618bd4027f206f4915ea4d6d9bfff.zip
Merge branch 'jetty-9.2.x'
Conflicts: jetty-client/src/main/java/org/eclipse/jetty/client/LeakTrackingConnectionPool.java jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientLoadTest.java jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientUploadDuringServerShutdown.java jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java jetty-spdy/spdy-server/src/test/java/org/eclipse/jetty/spdy/server/SynDataReplyDataLoadTest.java jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/TooFastClientTest.java
Diffstat (limited to 'jetty-servlet')
-rw-r--r--jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncIOServletTest.java63
1 files changed, 63 insertions, 0 deletions
diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncIOServletTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncIOServletTest.java
index 628573d8f0..784fb00daf 100644
--- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncIOServletTest.java
+++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncIOServletTest.java
@@ -46,6 +46,7 @@ import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.toolchain.test.AdvancedRunner;
import org.eclipse.jetty.toolchain.test.http.SimpleHttpParser;
import org.eclipse.jetty.toolchain.test.http.SimpleHttpResponse;
+import org.eclipse.jetty.util.IO;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
@@ -772,4 +773,66 @@ public class AsyncIOServletTest
Assert.assertFalse(allDataRead.get());
}
}
+
+
+ @Test
+ public void testEmptyAsyncRead() throws Exception
+ {
+ final AtomicBoolean oda = new AtomicBoolean();
+ final CountDownLatch latch = new CountDownLatch(1);
+
+ startServer(new HttpServlet()
+ {
+ @Override
+ protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+ {
+ final AsyncContext asyncContext = request.startAsync(request, response);
+ response.setStatus(200);
+ response.getOutputStream().close();
+ request.getInputStream().setReadListener(new ReadListener()
+ {
+ @Override
+ public void onDataAvailable() throws IOException
+ {
+ oda.set(true);
+ }
+
+ @Override
+ public void onAllDataRead() throws IOException
+ {
+ asyncContext.complete();
+ latch.countDown();
+ }
+
+ @Override
+ public void onError(Throwable t)
+ {
+ t.printStackTrace();
+ asyncContext.complete();
+ }
+ });
+ }
+ });
+
+ String request = "GET " + path + " HTTP/1.1\r\n" +
+ "Host: localhost:" + connector.getLocalPort() + "\r\n" +
+ "Connection: close\r\n" +
+ "\r\n";
+
+ try (Socket client = new Socket("localhost", connector.getLocalPort()))
+ {
+ OutputStream output = client.getOutputStream();
+ output.write(request.getBytes("UTF-8"));
+ output.flush();
+
+ String response = IO.toString(client.getInputStream());
+ assertThat(response,containsString(" 200 OK"));
+ // wait for onAllDataRead BEFORE closing client
+ latch.await();
+ }
+
+ // ODA not called at all!
+ Assert.assertFalse(oda.get());
+ }
+
}

Back to the top