Skip to content

Commit

Permalink
Correctly fix NPE in servlet AsyncListener
Browse files Browse the repository at this point in the history
This is the correct fix for #7449 as the spec says the following on
AsyncEvent.getSuppliedResponse():
> If the AsyncListener to which this AsyncEvent is being delivered was added using AsyncContext.addListener(AsyncListener, ServletRequest, ServletResponse), the returned ServletResponse will be the same as the one supplied to the above method. If the AsyncListener was added via AsyncContext.addListener(AsyncListener), this method must return null.
  • Loading branch information
jonasrutishauser committed Jan 16, 2024
1 parent e4445ab commit ae0fbbf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ public void onError(AsyncEvent event) {

@Override
public void onStartAsync(AsyncEvent event) {
event.getAsyncContext().addListener(this);
event
.getAsyncContext()
.addListener(this, event.getSuppliedRequest(), event.getSuppliedResponse());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ public void onError(AsyncEvent event) {

@Override
public void onStartAsync(AsyncEvent event) {
event.getAsyncContext().addListener(this);
event
.getAsyncContext()
.addListener(this, event.getSuppliedRequest(), event.getSuppliedResponse());
}
}
}

0 comments on commit ae0fbbf

Please sign in to comment.