Does Spring MVC has something like CancellationToken?

Viewed 612

HTTP request could be aborted on front-end at any time. At the moment I observe that my Spring application does not have a clue about this fact until I start writing the response to the wire. At the same time knowing that the request was aborted beforehand I could stop doing useless job by supporting cooperative cancellation.

ASP.NET has an implementation of request cancellation based on CancellationToken. I am looking for something similar for Spring but cannot find anything. I understand that CancellationToken gets particulary useful with async/await pattern but even without async/await it could have been useful.

So two questions:

  1. Does Spring MVC have this featre?
  2. If not, how its absence is typically worked-around? Of course, I could add another REST endpoint to notify the back-end that the request was cancelled, but this is a bit awkward. It's like re-inventing the concept that is already supported on protocol level.

And two bonus questions (in case the answer to Q1 is No):

  1. Does Spring team have plans for supporting it?
  2. Did they ever give any comments why this was not supported?

Thanks.

0 Answers
Related