diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractHttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractHttpConnection.java index 4882154ac4b..49fe8ca094f 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractHttpConnection.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractHttpConnection.java @@ -497,6 +497,8 @@ public abstract class AbstractHttpConnection extends AbstractConnection LOG.debug(e); error=true; _request.setHandled(true); + if (!_response.isCommitted()) + _generator.sendError(500, null, null, true); } catch (RuntimeIOException e) { @@ -549,9 +551,8 @@ public abstract class AbstractHttpConnection extends AbstractConnection { if (error) { - _generator.setPersistent(false); - _generator.flushBuffer(); _endp.shutdownOutput(); + _generator.setPersistent(false); if (!_generator.isComplete()) _response.complete(); } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/bio/SocketConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/bio/SocketConnector.java index 951c4632f26..1fea21f5e18 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/bio/SocketConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/bio/SocketConnector.java @@ -226,7 +226,12 @@ public class SocketConnector extends AbstractConnector { int l = super.fill(buffer); if (l<0) - close(); + { + if (!isInputShutdown()) + shutdownInput(); + if (isOutputShutdown()) + close(); + } return l; } 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 ca6ff52967f..16d62f5e658 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 @@ -194,7 +194,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture String response = readResponse(client); client.close(); -// assertThat("response contains 500", response.contains(" 500 "), is(true)); //TODO: check with gregw, + assertThat("response contains 500", response, Matchers.containsString(" 500 ")); assertThat("The 4th byte (-1) has not been passed to the handler", fourBytesRead.get(), is(false)); assertThat("EofException has been caught", earlyEOFException.get(), is(true)); } diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/SocketServerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/SocketServerTest.java index 0fbd19e31f3..f5717b84a67 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/SocketServerTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/SocketServerTest.java @@ -19,6 +19,8 @@ package org.eclipse.jetty.server; import org.eclipse.jetty.server.bio.SocketConnector; import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; /** * HttpServer Tester. @@ -30,4 +32,5 @@ public class SocketServerTest extends HttpServerTestBase { startServer(new SocketConnector()); } + }