Skip to content

The task in AsyncTaskExecutor throws an exception before execution, and ControllerAdvice will be called twice. #30232

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

Closed
babyblue94520 opened this issue Mar 30, 2023 · 1 comment
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Milestone

Comments

@babyblue94520
Copy link

Affects: <5.3.23>


I customized AsyncTaskExecutor to throw RejectedExecutionException when the queue is full, but I got twice the error message.

example

I spent some time writing this example to fully reproduce the problem,
Changing CustomAsyncTaskExecutor configuration on the fly is for the scenarios mentioned in README.md, not for actual use.

The current tracking result is that when DispatcherServlet processes async request, if the task throws an exception before entering AsyncExecutor, the data status in asyncManager is not processed normally, causing the request to enter DispatcherServlet again.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 30, 2023
@rstoyanchev rstoyanchev added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Apr 11, 2023
@rstoyanchev
Copy link
Contributor

Generally with async processing, we exit all the way from the Servlet container thread, and when the async result (whether success or exception) is ready, perform an async dispatch to continue processing on a Servlet container thread. This is why there is a a second call to @ExceptionHandler. The first one happens because you start async processing on the same thread, and we should be skipping exception handling at that point, but are not. I'll set this for a fix.

@rstoyanchev rstoyanchev self-assigned this Oct 2, 2023
@rstoyanchev rstoyanchev added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 2, 2023
@rstoyanchev rstoyanchev added this to the 6.1.0-RC1 milestone Oct 2, 2023
rstoyanchev added a commit that referenced this issue Feb 29, 2024
In preparation for a larger update, start by aligning with
6.1.x, which includes changes for gh-32042 and gh-30232.

See gh-32342
rstoyanchev added a commit that referenced this issue Feb 29, 2024
In preparation for a larger update, start by aligning with
6.1.x, which includes changes for gh-32042 and gh-30232.

See gh-32341
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants