diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContentProducer.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContentProducer.java index c8484963f6b..5a20690f5a4 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContentProducer.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContentProducer.java @@ -30,6 +30,14 @@ import org.slf4j.LoggerFactory; class AsyncContentProducer implements ContentProducer { private static final Logger LOG = LoggerFactory.getLogger(AsyncContentProducer.class); + private static final Throwable UNCONSUMED_CONTENT_EXCEPTION = new IOException("Unconsumed content") + { + @Override + public synchronized Throwable fillInStackTrace() + { + return this; + } + }; private final AutoLock _lock = new AutoLock(); private final HttpChannel _httpChannel; @@ -151,11 +159,15 @@ class AsyncContentProducer implements ContentProducer } @Override - public boolean consumeAll(Throwable x) + public boolean consumeAll() { assertLocked(); + Throwable x = UNCONSUMED_CONTENT_EXCEPTION; if (LOG.isDebugEnabled()) - LOG.debug("consumeAll [e={}] {}", x, this); + { + x = new IOException("Unconsumed content"); + LOG.debug("consumeAll {}", this, x); + } failCurrentContent(x); // A specific HttpChannel mechanism must be used as the following code // does not guarantee that the channel will synchronously deliver all diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/BlockingContentProducer.java b/jetty-server/src/main/java/org/eclipse/jetty/server/BlockingContentProducer.java index c525de21d4e..a4a499c2dd5 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/BlockingContentProducer.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/BlockingContentProducer.java @@ -80,9 +80,9 @@ class BlockingContentProducer implements ContentProducer } @Override - public boolean consumeAll(Throwable x) + public boolean consumeAll() { - boolean eof = _asyncContentProducer.consumeAll(x); + boolean eof = _asyncContentProducer.consumeAll(); _semaphore.release(); return eof; } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ContentProducer.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ContentProducer.java index 533a041ca1a..9678f02b3da 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/ContentProducer.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ContentProducer.java @@ -46,7 +46,7 @@ public interface ContentProducer * Doesn't change state. * @return true if EOF was reached. */ - boolean consumeAll(Throwable x); + boolean consumeAll(); /** * Check if the current data rate consumption is above the minimal rate. diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java index d7eee8efe7b..e41362b3a1c 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java @@ -150,10 +150,9 @@ public class HttpInput extends ServletInputStream implements Runnable { try (AutoLock lock = _contentProducer.lock()) { - IOException failure = new IOException("Unconsumed content"); if (LOG.isDebugEnabled()) - LOG.debug("consumeAll {}", this, failure); - boolean atEof = _contentProducer.consumeAll(failure); + LOG.debug("consumeAll {}", this); + boolean atEof = _contentProducer.consumeAll(); if (atEof) _consumedEof = true;