367048 test harness for guard on suspended requests
This commit is contained in:
parent
b7d8bd4f28
commit
569e930185
|
@ -64,7 +64,7 @@ public class AsyncHttpConnection extends AbstractHttpConnection implements Async
|
|||
// Handle resumed request
|
||||
if (_request._async.isAsync())
|
||||
{
|
||||
if ( _request._async.isDispatchable())
|
||||
if (_request._async.isDispatchable())
|
||||
handleRequest();
|
||||
}
|
||||
// else Parse more input
|
||||
|
|
|
@ -1,17 +1,33 @@
|
|||
package org.eclipse.jetty.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.io.nio.SelectChannelEndPoint;
|
||||
import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.junit.Test;
|
||||
|
||||
public class SelectChannelAsyncContextTest extends LocalAsyncContextTest
|
||||
{
|
||||
volatile SelectChannelEndPoint _endp;
|
||||
|
||||
@Override
|
||||
protected Connector initConnector()
|
||||
{
|
||||
return new SelectChannelConnector();
|
||||
return new SelectChannelConnector(){
|
||||
|
||||
@Override
|
||||
public void customize(EndPoint endpoint, Request request) throws IOException
|
||||
{
|
||||
super.customize(endpoint,request);
|
||||
_endp=(SelectChannelEndPoint)endpoint;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -23,4 +39,42 @@ public class SelectChannelAsyncContextTest extends LocalAsyncContextTest
|
|||
return IO.toString(socket.getInputStream());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuspendResumeWithAsyncDispatch() throws Exception
|
||||
{
|
||||
// Test that suspend/resume works in the face of spurious asyncDispatch call that may be
|
||||
// produced by the SslConnection
|
||||
final AtomicBoolean running = new AtomicBoolean(true);
|
||||
Thread thread = new Thread()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
while (running.get())
|
||||
{
|
||||
try
|
||||
{
|
||||
TimeUnit.MILLISECONDS.sleep(200);
|
||||
SelectChannelEndPoint endp=_endp;
|
||||
if (endp!=null && endp.isOpen())
|
||||
endp.asyncDispatch();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
thread.start();
|
||||
testSuspendResume();
|
||||
}
|
||||
finally
|
||||
{
|
||||
running.set(false);
|
||||
thread.join();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue