diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java index 1d2994139bc..e9f61ac1816 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java @@ -672,7 +672,6 @@ public class HttpChannel implements HttpParser.RequestHandler, Runnable * @param content the content buffer to write * @param complete whether the content is complete for the response * @param callback Callback when complete or failed - * @throws IOException if the write fails */ protected void write(ByteBuffer content, boolean complete, Callback callback) { @@ -698,6 +697,14 @@ public class HttpChannel implements HttpParser.RequestHandler, Runnable return getEndPoint() instanceof ChannelEndPoint; } + /** + * If a write or similar to this channel fails this method should be called. The standard implementation + * of {@link #failed()} is a noop. But the different implementations of HttpChannel might want to take actions. + */ + public void failed() + { + } + private class CommitCallback implements Callback { private final Callback _callback; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java index e5186cd9783..ab6dc4e4246 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java @@ -578,6 +578,12 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http _generator.setPersistent(false); super.handleException(x); } + + @Override + public void failed() + { + getEndPoint().shutdownOutput(); + } } private class CommitCallback extends IteratingCallback diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java index 4f6c5881698..62c93ac66c2 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java @@ -99,7 +99,7 @@ public class HttpOutput extends ServletOutputStream } catch(IOException e) { - _channel.getEndPoint().shutdownOutput(); + _channel.failed(); LOG.ignore(e); } releaseBuffer(); @@ -120,7 +120,7 @@ public class HttpOutput extends ServletOutputStream } catch(IOException e) { - _channel.getEndPoint().shutdownOutput(); + _channel.failed(); LOG.ignore(e); } } @@ -168,7 +168,7 @@ public class HttpOutput extends ServletOutputStream public void write(byte[] b, int off, int len) throws IOException { if (isClosed()) - throw new EOFException("Closed"); + throw new EOFException("Closed:" + System.identityHashCode(this)); _written+=len; boolean complete=_channel.getResponse().isAllContentWritten(_written);