Skip to content

Commit

Permalink
Do not fail callback in onFailure
Browse files Browse the repository at this point in the history
  • Loading branch information
gregw committed Nov 1, 2023
1 parent 649fb94 commit 4be8b24
Showing 1 changed file with 4 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -457,34 +457,20 @@ else if (ExceptionUtil.areNotAssociated(_failure.getFailure(), x) && _failure.ge
Runnable invokeWriteFailure = _response.lockedFailWrite(x);

// Create runnable to invoke any onError listeners
ChannelRequest request = _request;
Runnable invokeOnFailureListeners = () ->
{
Consumer<Throwable> onFailure;
try (AutoLock ignore = _lock.lock())
{
onFailure = _onFailure;
}

Consumer<Throwable> onFailure = _onFailure;
Runnable invokeOnFailureListeners = onFailure == null ? null : () ->
{
try
{
if (LOG.isDebugEnabled())
LOG.debug("invokeListeners {} {}", HttpChannelState.this, onFailure, x);
if (onFailure != null)
onFailure.accept(x);
onFailure.accept(x);
}
catch (Throwable throwable)
{
ExceptionUtil.addSuppressedIfNotAssociated(x, throwable);
}

// If the application has not been otherwise informed of the failure
if (invokeOnContentAvailable == null && invokeWriteFailure == null && onFailure == null)
{
if (LOG.isDebugEnabled())
LOG.debug("failing callback in {}", this, x);
request._callback.failed(x);
}
};

// Serialize all the error actions.
Expand Down

0 comments on commit 4be8b24

Please sign in to comment.