diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/AsyncEchoServlet.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/AsyncEchoServlet.java index 74231763c8f..9a557cce46e 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/AsyncEchoServlet.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/AsyncEchoServlet.java @@ -34,6 +34,8 @@ import javax.servlet.http.HttpServletResponse; public class AsyncEchoServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + @Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { @@ -62,17 +64,22 @@ public class AsyncEchoServlet extends HttpServlet @Override public void onDataAvailable() throws IOException { - onWritePossible(); + handleAsyncIO(); } @Override public void onAllDataRead() throws IOException { - onWritePossible(); + handleAsyncIO(); } @Override public void onWritePossible() throws IOException + { + handleAsyncIO(); + } + + private void handleAsyncIO() throws IOException { // This method is called: // 1) after first registering a WriteListener (ready for first write) @@ -81,8 +88,17 @@ public class AsyncEchoServlet extends HttpServlet // 4) from an input callback // We should try to read, only if we are able to write! - while (output.isReady() && input.isReady()) + while (true) { + if (!output.isReady()) + // Don't even try to read anything until it is possible to write something, + // when onWritePossible will be called + break; + + if (!input.isReady()) + // Nothing available to read, so wait for another call to onDataAvailable + break; + int read = input.read(buffer); if (read<0) { @@ -100,7 +116,7 @@ public class AsyncEchoServlet extends HttpServlet @Override public void onError(Throwable failure) { - failure.printStackTrace(); + new Throwable("onError",failure).printStackTrace(); asyncContext.complete(); } } diff --git a/examples/embedded/src/main/resources/jetty-logging.properties b/examples/embedded/src/main/resources/jetty-logging.properties index 62624e2d4a4..7bffba83dbb 100644 --- a/examples/embedded/src/main/resources/jetty-logging.properties +++ b/examples/embedded/src/main/resources/jetty-logging.properties @@ -1,8 +1,8 @@ #org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.JavaUtilLog #org.eclipse.jetty.util.log.javautil.PROPERTIES=java-util-logging.properties #org.eclipse.jetty.util.log.SOURCE=true -org.eclipse.jetty.LEVEL=INFO -org.eclipse.jetty.STACKS=true +#org.eclipse.jetty.LEVEL=INFO +#org.eclipse.jetty.STACKS=true #org.eclipse.jetty.STACKS=false #org.eclipse.jetty.io.LEVEL=DEBUG #org.eclipse.jetty.io.ssl.LEVEL=DEBUG diff --git a/jetty-runner/pom.xml b/jetty-runner/pom.xml index c7eb427888e..00caae19f2b 100644 --- a/jetty-runner/pom.xml +++ b/jetty-runner/pom.xml @@ -42,8 +42,6 @@ true - bundle-manifest - process-classes manifest diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java index 1330a1f80b5..926a7a6b83d 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java @@ -948,6 +948,8 @@ public class HttpOutput extends ServletOutputStream implements Runnable // occurred, we need to call onWritePossible to tell async // producer that the last write completed. // So fall through + case PENDING: + case UNREADY: case READY: try {