added test for async IO isNotReadyAtEOF

This commit is contained in:
Greg Wilkins 2015-02-04 12:40:36 +11:00
parent 40ffac3339
commit 47055dd2c8
4 changed files with 23 additions and 16 deletions

View File

@ -348,19 +348,6 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
}
}
catch (Error e)
{
if ("ContinuationThrowable".equals(e.getClass().getSimpleName()))
LOG.ignore(e);
else
{
error=true;
LOG.warn(String.valueOf(_request.getHttpURI()), e);
_state.error(e);
_request.setHandled(true);
handleException(e);
}
}
catch (EofException|QuietServletException e)
{
error=true;
@ -377,6 +364,19 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
_request.setHandled(true);
handleException(e);
}
catch (Throwable e)
{
if ("ContinuationThrowable".equals(e.getClass().getSimpleName()))
LOG.ignore(e);
else
{
error=true;
LOG.warn(String.valueOf(_request.getHttpURI()), e);
_state.error(e);
_request.setHandled(true);
handleException(e);
}
}
finally
{
if (error && _state.isAsyncStarted())

View File

@ -531,7 +531,7 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
{
if (parseContent())
_channel.handle();
else
else if (!_input.isFinished())
asyncReadFillInterested();
}

View File

@ -470,6 +470,9 @@ public abstract class HttpInput extends ServletInputStream implements Runnable
synchronized (_inputQ)
{
if (_state==EOF)
return;
if (_state==AEOF)
{
_state=EOF;

View File

@ -40,11 +40,13 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.Server;
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.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.instanceOf;
@ -53,6 +55,7 @@ import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
@RunWith (AdvancedRunner.class)
public class AsyncIOServletTest
{
private Server server;
@ -64,6 +67,7 @@ public class AsyncIOServletTest
{
server = new Server();
connector = new ServerConnector(server);
connector.setIdleTimeout(30000);
server.addConnector(connector);
context = new ServletContextHandler(server, "/", false, false);
@ -417,7 +421,7 @@ public class AsyncIOServletTest
@Test
public void testIsNotReadyAtEOF() throws Exception
{
String text = "Test\n";
String text = "TEST\n";
final byte[] data = text.getBytes(StandardCharsets.ISO_8859_1);
startServer(new HttpServlet()
@ -490,7 +494,7 @@ public class AsyncIOServletTest
while (line.length()>0)
line=in.readLine();
line=in.readLine();
assertThat(line, containsString("i="+data.length+" eof=false finished=true"));
assertThat(line, containsString("i="+data.length+" eof=true finished=true"));
}
}
}