Skip to content

WebAsyncManager should cancel task thread on timeout [SPR-15852] #20407

Closed
@spring-projects-issues

Description

@spring-projects-issues

Jordi Puigsegur opened SPR-15852 and commented

Hi,

We are implementing a REST service with and endpoint that does some processing, part of it being in a database transaction. We would like to use WebAsyncTask to run this task in a separate thread and establish a timeout. However, we find that when the timeout has elapsed the service returns the corresponding Timeout Exception but the thread continues to work finishing the database transaction while we would like it to fail and perform a rollback.

We understand that the way to control it is by honoring isInterrupted() inside our code before committing the transaction. This way the executor thread will know that the timeout has exceeded and will exit with an exception performing a rollback. However it seems that the thread is not interrupted.

Which is the right way to do this? Is the spring platform supposed to call .interrupt() when the timeout is activated or we have to do this ourselves?

Thanks,
Jordi.


Affects: 4.3.5

Reference URL: https://github.com/spring-projects/spring-framework/blob/master/spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncTask.java

Referenced from: commits 681ced8, 8b7a670

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions