Fixes #960 - Async I/O spin when reading early EOF.

AsyncIOServletTest is now testing HTTP/1.1 and HTTP/2 transports.
This commit is contained in:
Simone Bordet 2016-09-26 11:49:57 +02:00
parent ad00e19328
commit 74b86bad35
6 changed files with 510 additions and 448 deletions

View File

@ -991,8 +991,8 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
protected void abort(Throwable failure)
{
terminate();
notifyFailure(this, failure);
terminate();
}
public boolean isDisconnected()

View File

@ -134,6 +134,12 @@ public class HTTP2ServerConnectionFactory extends AbstractHTTP2ServerConnectionF
getConnection().onSessionFailure(new IOException("HTTP/2 " + error + reason));
}
@Override
public void onFailure(Session session, Throwable failure)
{
getConnection().onSessionFailure(failure);
}
@Override
public void onHeaders(Stream stream, HeadersFrame frame)
{

View File

@ -296,8 +296,10 @@ public class HttpChannelOverHTTP2 extends HttpChannel
public void onFailure(Throwable failure)
{
onEarlyEOF();
getState().asyncError(failure);
if (onEarlyEOF())
handle();
else
getState().asyncError(failure);
}
protected void consumeInput()

View File

@ -61,7 +61,7 @@
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<artifactId>jetty-servlet</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

View File

@ -21,6 +21,8 @@ package org.eclipse.jetty.http.client;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServlet;
import org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.HttpClientTransport;
@ -40,6 +42,8 @@ import org.eclipse.jetty.server.SecureRequestCustomizer;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.SslConnectionFactory;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.toolchain.test.TestTracker;
import org.eclipse.jetty.util.SocketAddressResolver;
import org.eclipse.jetty.util.ssl.SslContextFactory;
@ -67,6 +71,8 @@ public abstract class AbstractTest
protected SslContextFactory sslContextFactory;
protected Server server;
protected ServerConnector connector;
protected ServletContextHandler context;
protected String servletPath = "/servlet";
protected HttpClient client;
public AbstractTest(Transport transport)
@ -81,6 +87,22 @@ public abstract class AbstractTest
startClient();
}
public void start(HttpServlet servlet) throws Exception
{
startServer(servlet);
startClient();
}
protected void startServer(HttpServlet servlet) throws Exception
{
context = new ServletContextHandler();
context.setContextPath("/");
ServletHolder holder = new ServletHolder(servlet);
holder.setAsyncSupported(true);
context.addServlet(holder, servletPath);
startServer(context);
}
protected void startServer(Handler handler) throws Exception
{
sslContextFactory = new SslContextFactory();
@ -228,9 +250,19 @@ public abstract class AbstractTest
@After
public void stop() throws Exception
{
stopClient();
stopServer();
}
protected void stopClient() throws Exception
{
if (client != null)
client.stop();
}
protected void stopServer() throws Exception
{
if (server != null)
server.stop();
}