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 RESTEasy Reactive race #19490

Merged
merged 1 commit into from
Aug 19, 2021
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,15 @@ public void run() {
//if this is a blocking target we don't activate for the initial non-blocking part
//unless there are pre-mapping filters as these may require CDI
boolean disasociateRequestScope = false;
boolean aborted = false;
Executor exec = null;
try {
while (position < handlers.length) {
int pos = position;
position++; //increment before, as reset may reset it to zero
try {
handlers[pos].handle((T) this);
if (suspended) {
Executor exec = null;
synchronized (this) {
if (isRequestScopeManagementRequired()) {
if (requestScopeActivated) {
Expand All @@ -151,40 +152,29 @@ public void run() {
exec = this.executor;
// prevent future suspensions from re-submitting the task
this.executor = null;
return;
} else if (suspended) {
running = false;
processingSuspended = true;
return;
}
}
if (exec != null) {
//outside sync block
exec.execute(this);
processingSuspended = true;
return;
}
}
} catch (Throwable t) {
boolean over = handlers == abortHandlerChain;
aborted = handlers == abortHandlerChain;
if (t instanceof PreserveTargetException) {
handleException(t.getCause(), true);
} else {
handleException(t);
}
if (over) {
running = false;
return;
}
}
}
running = false;
} catch (Throwable t) {
handleUnrecoverableError(t);
running = false;
} finally {
// we need to make sure we don't close the underlying stream in the event loop if the task
// has been offloaded to the executor
if (position == handlers.length && !processingSuspended) {
if ((position == handlers.length && !processingSuspended) || aborted) {
close();
} else {
if (disasociateRequestScope) {
Expand All @@ -193,6 +183,13 @@ public void run() {
}
beginAsyncProcessing();
}
synchronized (this) {
running = false;
}
if (exec != null) {
//outside sync block
exec.execute(this);
}
}
}

Expand Down