Skip to content

Commit

Permalink
Issue #4855 - Occasional h2spec failures on CI
Browse files Browse the repository at this point in the history
Updates after review.

Signed-off-by: Simone Bordet <[email protected]>
  • Loading branch information
sbordet committed Jun 8, 2020
1 parent ee51839 commit 56d3a6e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,10 @@ private class TransportCallback implements Callback
private boolean _commit;
private Throwable _failure;

private void reset()
private void reset(boolean failed)
{
assert Thread.holdsLock(this);
_state = State.IDLE;
_state = failed ? State.FAILED : State.IDLE;
_callback = null;
_commit = false;
_failure = null;
Expand Down Expand Up @@ -453,26 +453,25 @@ private void pending()
callback = _callback;
commit = _commit;
failure = null;
reset();
reset(false);
break;
}
case FAILING:
{
// The send already completed with a failure, but
// the call to failed() was delayed, so call it now.
_state = State.FAILED;
callback = _callback;
commit = _commit;
failure = _failure;
reset(true);
break;
}
default:
{
_state = State.FAILED;
_failure = new IllegalStateException("Invalid transport state: " + _state);
callback = _callback;
commit = _commit;
failure = _failure;
failure = new IllegalStateException("Invalid transport state: " + _state);
reset(true);
break;
}
}
Expand Down Expand Up @@ -502,7 +501,7 @@ public void succeeded()
{
callback = _callback;
commit = _commit;
reset();
reset(false);
break;
}
default:
Expand Down Expand Up @@ -535,10 +534,9 @@ public void failed(Throwable failure)
case IDLE:
case PENDING:
{
_state = State.FAILED;
_failure = failure;
callback = _callback;
commit = _commit;
reset(true);
break;
}
default:
Expand All @@ -563,10 +561,9 @@ private boolean idleTimeout(Throwable failure)
case PENDING:
{
// The send was started but idle timed out, fail it.
_state = State.FAILED;
_failure = failure;
callback = _callback;
timeout = true;
reset(true);
break;
}
case IDLE:
Expand All @@ -587,13 +584,12 @@ private boolean idleTimeout(Throwable failure)
default:
{
// Should not happen, but just in case.
_state = State.FAILED;
_failure = new IllegalStateException("Invalid transport state: " + _state, failure);
callback = _callback;
if (callback == null)
callback = Callback.NOOP;
timeout = true;
failure = _failure;
failure = new IllegalStateException("Invalid transport state: " + _state, failure);
reset(true);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -817,14 +817,12 @@ protected void onError(Throwable th)
// check the actions of the listeners
synchronized (this)
{
// If we are still async and nobody has called sendError
if (_requestState == RequestState.ASYNC && !_sendError)
{
// Then the listeners did not invoke API methods
// and the container must provide a default error dispatch.
// The listeners did not invoke API methods and the
// container must provide a default error dispatch.
sendError(th);
}
// Otherwise the listeners have called AsyncContext.complete().
else if (_requestState != RequestState.COMPLETE)
{
LOG.warn("unhandled in state " + _requestState, new IllegalStateException(th));
Expand Down

0 comments on commit 56d3a6e

Please sign in to comment.