nhibernate / nhibernate-core

NHibernate Object Relational Mapper
https://nhibernate.info
GNU Lesser General Public License v2.1
2.13k stars 931 forks source link

NHibernate.Engine.ActionQueue.ExecuteAsync hides TaskCanceledException #3592

Open Madajevas opened 3 months ago

Madajevas commented 3 months ago

If provided cancellation token gets cancelled during execution of InnerExecuteAsync method and any listener code checks token and throws exception it gets lost because regardless of cancellation token state finally block gets executed where PreInvalidateCachesAsync method checks token again and throws exception of its own. I would advice to not call that method if cancellation was requested and allow exception to bubble.

https://github.com/nhibernate/nhibernate-core/blob/8a1b0848c3a521f1d99d48c1817487b9e514ec51/src/NHibernate/Async/Engine/ActionQueue.cs#L55-L66

hazzik commented 3 months ago

Thanks. Good catch.

@maca88, we would probably need to change the async generator to account for this situations.