Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix npe when onCompleteFailure happens after reset #12199

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
don't use the exchange field from the error path
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
lorban committed Aug 28, 2024

Verified

This commit was signed with the committer’s verified signature.
lorban Ludovic Orban
commit 327d001766884ab7a60df0f5c2a755c24a1a4ce9
Original file line number Diff line number Diff line change
@@ -376,7 +376,7 @@ private void externalAbort(Throwable failure, Promise<Boolean> promise)
if (abort)
{
contentSender.abort = promise;
contentSender.abort(this.failure.get()); // this is going to call internalAbort()
contentSender.abort(this.failure.get());
}
else
{
@@ -386,16 +386,13 @@ private void externalAbort(Throwable failure, Promise<Boolean> promise)
}
}

private void internalAbort(HttpExchange exchange, Throwable failure)
private void internalAbort(Throwable failure)
{
// internalAbort() may be called from externalAbort() (which already called anyToFailure)
// so we cannot rely on its return code to figure out if abortRequest() should be called or not.
HttpExchange exchange = getHttpExchange();
if (exchange == null)
return;
anyToFailure(failure);
// internalAbort() may be called after ContentSender.reset() so exchange might be null.
if (exchange != null)
abortRequest(exchange);
else
dispose();
abortRequest(exchange);
}

private boolean updateRequestState(RequestState from, RequestState to)
@@ -632,7 +629,7 @@ protected void onCompleteFailure(Throwable x)
}

failRequest(x);
internalAbort(exchange, x);
internalAbort(x);

Promise<Boolean> promise = abort;
if (promise != null)