Skip to content

Commit

Permalink
Issue #8211 - changes from review
Browse files Browse the repository at this point in the history
Signed-off-by: Lachlan Roberts <[email protected]>
  • Loading branch information
lachlan-roberts committed Jul 4, 2022
1 parent 5253641 commit 0764d55
Showing 1 changed file with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -662,16 +662,9 @@ public void run()
{
failure = x;
}

if (failure != null)
{
try (AutoLock ignored = _lock.lock())
{
if (request._httpChannel != null && !request._httpChannel._completed)
request._callback.failed(failure);
else if (LOG.isDebugEnabled())
LOG.debug("Process failed", failure);
}
}
_request._callback.ensureCompleted(failure);

HttpStream stream;
boolean completeStream;
Expand Down Expand Up @@ -1373,6 +1366,8 @@ public void failed(Throwable failure)
try (AutoLock ignored = _request._lock.lock())
{
request = _request;

// Be forgiving of applications that report a failure that is already known by treating as a noop.
if (request._httpChannel != null && request._httpChannel._error != null && TypeUtil.isAssociated(request._httpChannel._error.getCause(), failure))
return;
lockedOnComplete();
Expand Down Expand Up @@ -1436,6 +1431,25 @@ private void lockedOnComplete()
httpChannelState._completed = true;
}

public void ensureCompleted(Throwable failure)
{
HttpChannelState httpChannel = _request._httpChannel;
if (httpChannel != null)
{
try (AutoLock ignored = httpChannel._lock.lock())
{
if (!httpChannel._completed)
{
failed(failure);
return;
}
}
}

if (LOG.isDebugEnabled())
LOG.debug("Process failed", failure);
}

@Override
public InvocationType getInvocationType()
{
Expand Down

0 comments on commit 0764d55

Please sign in to comment.