Skip to content

Commit

Permalink
ErrorContent must not hold a null exception
Browse files Browse the repository at this point in the history
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
  • Loading branch information
lorban committed Jun 7, 2022
1 parent b199c71 commit 79973da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class AsyncContentProducer implements ContentProducer
{
private static final Logger LOG = LoggerFactory.getLogger(AsyncContentProducer.class);
private static final HttpInput.ErrorContent RECYCLED_ERROR_CONTENT = new HttpInput.ErrorContent(new IllegalStateException("ContentProducer has been recycled"));
private static final HttpInput.ErrorContent FAILED_ERROR_CONTENT = new HttpInput.ErrorContent(new UnconsumedContentException());

private final AutoLock _lock = new AutoLock();
private final HttpChannel _httpChannel;
Expand Down Expand Up @@ -226,9 +227,13 @@ private void failCurrentContent(Throwable x)
_rawContent = null;
}

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ public static final class ErrorContent extends SpecialContent

public ErrorContent(Throwable error)
{
_error = error;
_error = Objects.requireNonNull(error);
}

@Override
Expand Down

0 comments on commit 79973da

Please sign in to comment.