Skip to content

Commit

Permalink
re-introduce static SENTINEL_ERROR_CONTENT with an exception that doe…
Browse files Browse the repository at this point in the history
…s not record suppressed exceptions

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
  • Loading branch information
lorban committed Jun 9, 2022
1 parent 7a26b4e commit ac2c862
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
Expand Up @@ -31,7 +31,7 @@
class AsyncContentProducer implements ContentProducer
{
private static final Logger LOG = LoggerFactory.getLogger(AsyncContentProducer.class);
private static final HttpInput.Content EOF = new HttpInput.EofContent();
private static final HttpInput.ErrorContent SENTINEL_ERROR_CONTENT = new HttpInput.ErrorContent(new UnconsumedContentException());

private final AutoLock _lock = new AutoLock();
private final HttpChannel _httpChannel;
Expand Down Expand Up @@ -63,12 +63,12 @@ public void recycle()
// Make sure that the content has been fully consumed before destroying the interceptor and also make sure
// that asking this instance for content between recycle and reopen will only produce EOF content.
if (_rawContent == null)
_rawContent = EOF;
_rawContent = SENTINEL_ERROR_CONTENT;
else if (!_rawContent.isSpecial())
throw new IllegalStateException("ContentProducer with unconsumed content cannot be recycled");

if (_transformedContent == null)
_transformedContent = EOF;
_transformedContent = SENTINEL_ERROR_CONTENT;
else if (!_transformedContent.isSpecial())
throw new IllegalStateException("ContentProducer with unconsumed content cannot be recycled");

Expand Down Expand Up @@ -226,13 +226,9 @@ private void failCurrentContent(Throwable x)
_rawContent = null;
}

HttpInput.Content finalContent;
if (x != null)
finalContent = new HttpInput.ErrorContent(x);
else
finalContent = null;
_transformedContent = finalContent;
_rawContent = finalContent;
HttpInput.ErrorContent errorContent = x == null ? SENTINEL_ERROR_CONTENT : new HttpInput.ErrorContent(x);
_transformedContent = errorContent;
_rawContent = errorContent;
}

@Override
Expand Down
Expand Up @@ -13,8 +13,6 @@

package org.eclipse.jetty.server;

import java.io.IOException;

import org.eclipse.jetty.util.component.Destroyable;
import org.eclipse.jetty.util.thread.AutoLock;
import org.slf4j.Logger;
Expand Down Expand Up @@ -155,23 +153,15 @@ public interface ContentProducer

/**
* This exception used to report when there is some unconsumed content left at the end of a request's processing.
* Suppressed exceptions are disabled, meaning calling {@link #addSuppressed(Throwable)} has no effect.
*/
class UnconsumedContentException extends IOException
class UnconsumedContentException extends Exception
{
private static final Logger LOG = LoggerFactory.getLogger(UnconsumedContentException.class);

public UnconsumedContentException()
{
super("Unconsumed content");
}

@Override
public Throwable fillInStackTrace()
{
if (LOG.isDebugEnabled())
return super.fillInStackTrace();
else
return this;
super("Unconsumed content", null, false, LOG.isDebugEnabled());
}
}
}

0 comments on commit ac2c862

Please sign in to comment.