Skip to content

Commit

Permalink
[UNDERTOW-2338] Fix NPE by making sure asyncStart is true only if asy…
Browse files Browse the repository at this point in the history
…ncContext is initialized

Signed-off-by: Flavia Rainone <frainone@redhat.com>
  • Loading branch information
fl4via committed Feb 13, 2024
1 parent 489e145 commit c81583a
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1075,9 +1075,10 @@ public AsyncContext startAsync() throws IllegalStateException {
} else if (asyncStarted) {
throw UndertowServletMessages.MESSAGES.asyncAlreadyStarted();
}
asyncStarted = true;
final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
return asyncContext = new AsyncContextImpl(exchange, servletRequestContext.getServletRequest(), servletRequestContext.getServletResponse(), servletRequestContext, false, asyncContext);
asyncContext = new AsyncContextImpl(exchange, servletRequestContext.getServletRequest(), servletRequestContext.getServletResponse(), servletRequestContext, false, asyncContext);
asyncStarted = true;
return asyncContext;
}

@Override
Expand All @@ -1100,10 +1101,11 @@ public AsyncContext startAsync(final ServletRequest servletRequest, final Servle
} else if (asyncStarted) {
throw UndertowServletMessages.MESSAGES.asyncAlreadyStarted();
}
asyncStarted = true;
servletRequestContext.setServletRequest(servletRequest);
servletRequestContext.setServletResponse(servletResponse);
return asyncContext = new AsyncContextImpl(exchange, servletRequest, servletResponse, servletRequestContext, true, asyncContext);
asyncContext = new AsyncContextImpl(exchange, servletRequest, servletResponse, servletRequestContext, true, asyncContext);
asyncStarted = true;
return asyncContext;
}

@Override
Expand Down

0 comments on commit c81583a

Please sign in to comment.