Merge remote-tracking branch 'origin/jetty-9.3.x'
This commit is contained in:
commit
2d2c321845
|
@ -34,6 +34,8 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
public class AsyncEchoServlet extends HttpServlet
|
public class AsyncEchoServlet extends HttpServlet
|
||||||
{
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
|
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
|
||||||
{
|
{
|
||||||
|
@ -62,17 +64,22 @@ public class AsyncEchoServlet extends HttpServlet
|
||||||
@Override
|
@Override
|
||||||
public void onDataAvailable() throws IOException
|
public void onDataAvailable() throws IOException
|
||||||
{
|
{
|
||||||
onWritePossible();
|
handleAsyncIO();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAllDataRead() throws IOException
|
public void onAllDataRead() throws IOException
|
||||||
{
|
{
|
||||||
onWritePossible();
|
handleAsyncIO();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWritePossible() throws IOException
|
public void onWritePossible() throws IOException
|
||||||
|
{
|
||||||
|
handleAsyncIO();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleAsyncIO() throws IOException
|
||||||
{
|
{
|
||||||
// This method is called:
|
// This method is called:
|
||||||
// 1) after first registering a WriteListener (ready for first write)
|
// 1) after first registering a WriteListener (ready for first write)
|
||||||
|
@ -81,8 +88,17 @@ public class AsyncEchoServlet extends HttpServlet
|
||||||
// 4) from an input callback
|
// 4) from an input callback
|
||||||
|
|
||||||
// We should try to read, only if we are able to write!
|
// 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);
|
int read = input.read(buffer);
|
||||||
if (read<0)
|
if (read<0)
|
||||||
{
|
{
|
||||||
|
@ -100,7 +116,7 @@ public class AsyncEchoServlet extends HttpServlet
|
||||||
@Override
|
@Override
|
||||||
public void onError(Throwable failure)
|
public void onError(Throwable failure)
|
||||||
{
|
{
|
||||||
failure.printStackTrace();
|
new Throwable("onError",failure).printStackTrace();
|
||||||
asyncContext.complete();
|
asyncContext.complete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.JavaUtilLog
|
#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.javautil.PROPERTIES=java-util-logging.properties
|
||||||
#org.eclipse.jetty.util.log.SOURCE=true
|
#org.eclipse.jetty.util.log.SOURCE=true
|
||||||
org.eclipse.jetty.LEVEL=INFO
|
#org.eclipse.jetty.LEVEL=INFO
|
||||||
org.eclipse.jetty.STACKS=true
|
#org.eclipse.jetty.STACKS=true
|
||||||
#org.eclipse.jetty.STACKS=false
|
#org.eclipse.jetty.STACKS=false
|
||||||
#org.eclipse.jetty.io.LEVEL=DEBUG
|
#org.eclipse.jetty.io.LEVEL=DEBUG
|
||||||
#org.eclipse.jetty.io.ssl.LEVEL=DEBUG
|
#org.eclipse.jetty.io.ssl.LEVEL=DEBUG
|
||||||
|
|
|
@ -42,8 +42,6 @@
|
||||||
<extensions>true</extensions>
|
<extensions>true</extensions>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>bundle-manifest</id>
|
|
||||||
<phase>process-classes</phase>
|
|
||||||
<goals>
|
<goals>
|
||||||
<goal>manifest</goal>
|
<goal>manifest</goal>
|
||||||
</goals>
|
</goals>
|
||||||
|
|
|
@ -948,6 +948,8 @@ public class HttpOutput extends ServletOutputStream implements Runnable
|
||||||
// occurred, we need to call onWritePossible to tell async
|
// occurred, we need to call onWritePossible to tell async
|
||||||
// producer that the last write completed.
|
// producer that the last write completed.
|
||||||
// So fall through
|
// So fall through
|
||||||
|
case PENDING:
|
||||||
|
case UNREADY:
|
||||||
case READY:
|
case READY:
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue