diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java index 4b8e0a55d1d..08dcbb4aeda 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java @@ -408,7 +408,7 @@ public class SslConnection extends AbstractConnection implements AsyncConnection } // If we are reading into the temp buffer and it has some content, then we should be dispatched. - if (toFill==_unwrapBuf && _unwrapBuf.hasContent()) + if (toFill==_unwrapBuf && _unwrapBuf.hasContent() && !_connection.isSuspended()) _aEndp.asyncDispatch(); } finally @@ -550,7 +550,7 @@ public class SslConnection extends AbstractConnection implements AsyncConnection break; case BUFFER_OVERFLOW: - _logger.debug("{} unwrap {} {}->{}",_session,result.getStatus(),_inbound.toDetailString(),buffer.toDetailString()); + if (_logger.isDebugEnabled()) _logger.debug("{} unwrap {} {}->{}",_session,result.getStatus(),_inbound.toDetailString(),buffer.toDetailString()); break; case OK: diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java index de3cc399594..ccc53ba9e30 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java @@ -39,9 +39,11 @@ import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.StdErrLog; +import org.hamcrest.CoreMatchers; import org.hamcrest.Matchers; import org.junit.Test; import org.junit.matchers.JUnitMatchers; +import org.mockito.internal.matchers.Contains; import static org.hamcrest.Matchers.greaterThanOrEqualTo; import static org.junit.Assert.assertEquals; @@ -1280,4 +1282,51 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture response.setStatus(200); } } + + + @Test + public void testSuspendedPipeline() throws Exception + { + SuspendHandler suspend = new SuspendHandler(); + suspend.setSuspendFor(30000); + suspend.setResumeAfter(1000); + configureServer(suspend); + + long start=System.currentTimeMillis(); + Socket client=newSocket(HOST,_connector.getLocalPort()); + try + { + OutputStream os=client.getOutputStream(); + InputStream is=client.getInputStream(); + + // write an initial request + os.write(( + "GET / HTTP/1.1\r\n"+ + "host: "+HOST+":"+_connector.getLocalPort()+"\r\n"+ + "\r\n" + ).getBytes()); + os.flush(); + + Thread.sleep(200); + + // write an pipelined request + os.write(( + "GET / HTTP/1.1\r\n"+ + "host: "+HOST+":"+_connector.getLocalPort()+"\r\n"+ + "connection: close\r\n"+ + "\r\n" + ).getBytes()); + os.flush(); + + String response=readResponse(client); + assertThat(response,JUnitMatchers.containsString("RESUMEDHTTP/1.1 200 OK")); + assertThat((System.currentTimeMillis()-start),greaterThanOrEqualTo(1999L)); + + // TODO This test should also check that that the CPU did not spin during the suspend. + } + finally + { + client.close(); + } + } } diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/SelectChannelServerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/SelectChannelServerTest.java index d32593a83e2..b8f2b2c55a7 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/SelectChannelServerTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/SelectChannelServerTest.java @@ -31,6 +31,13 @@ public class SelectChannelServerTest extends HttpServerTestBase { super.testCommittedError(); } + + @Override + public void testSuspendedPipeline() throws Exception + { + // TODO Auto-generated method stub + super.testSuspendedPipeline(); + } } diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/SuspendHandler.java b/jetty-server/src/test/java/org/eclipse/jetty/server/SuspendHandler.java index f5ea64c3bd1..1c16dc956ab 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/SuspendHandler.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/SuspendHandler.java @@ -121,8 +121,7 @@ class SuspendHandler extends HandlerWrapper try { Thread.sleep(_resumeAfter); - if(((HttpServletRequest)asyncContext.getRequest()).getSession(true).getId()!=null) - asyncContext.dispatch(); + asyncContext.dispatch(); } catch(Exception e) { diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SelectChannelServerSslTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SelectChannelServerSslTest.java index f669bb53689..2e6883a2968 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SelectChannelServerSslTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SelectChannelServerSslTest.java @@ -144,5 +144,10 @@ public class SelectChannelServerSslTest extends HttpServerTestBase { } - + + @Override + public void testSuspendedPipeline() throws Exception + { + super.testSuspendedPipeline(); + } }