nhibernate-core icon indicating copy to clipboard operation
nhibernate-core copied to clipboard

NHibernate.Engine.ActionQueue.ExecuteAsync hides TaskCanceledException

Open Madajevas opened this issue 1 year ago • 1 comments

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

Madajevas avatar Jul 29 '24 11:07 Madajevas

Thanks. Good catch.

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

hazzik avatar Jul 29 '24 11:07 hazzik