Skip to content

Commit

Permalink
fix BlockingTest.testBlockingReadAndBlockingWriteGzipped hanging b/c …
Browse files Browse the repository at this point in the history
…two writes are being done but only one got its callback failed

Signed-off-by: Ludovic Orban <[email protected]>
  • Loading branch information
lorban committed Dec 9, 2024
1 parent 546cdd9 commit debb110
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1340,8 +1340,9 @@ public void failed(Throwable x)
{
if (LOG.isDebugEnabled())
LOG.debug("write failed {}", this, x);
Callback callback;
Callback callback = null;
HttpChannelState httpChannel;
Throwable noChannelFailure = null;
try (AutoLock ignored = _request._lock.lock())
{
_writeFailure = x;
Expand All @@ -1350,8 +1351,22 @@ public void failed(Throwable x)
httpChannel = _request.lockedGetHttpChannelState();
httpChannel.lockedStreamSendCompleted(false);
}
if (callback != null)
httpChannel._writeInvoker.run(() -> HttpChannelState.failed(callback, x));
catch (Throwable failure)
{
httpChannel = null;
noChannelFailure = failure;
}

if (httpChannel == null)
{
// Channel already completed, just fail the callback.
HttpChannelState.failed(callback, noChannelFailure);
}
else
{
Callback cb = callback;
httpChannel._writeInvoker.run(() -> HttpChannelState.failed(cb, x));
}
}

@Override
Expand Down

0 comments on commit debb110

Please sign in to comment.