File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change 16
16
using NUnit . Framework . Interfaces ;
17
17
using System . Text ;
18
18
using static NUnit . Framework . TestContext ;
19
+ using System . Threading ;
19
20
20
21
namespace NHibernate . Test
21
22
{
@@ -221,13 +222,26 @@ private bool CheckSessionsWereClosed()
221
222
var allClosed = true ;
222
223
foreach ( var session in _openedSessions )
223
224
{
224
- session . GetSessionImplementation ( ) . TransactionContext ? . WaitOne ( ) ;
225
- if ( session . IsOpen )
225
+ var txContext = session . GetSessionImplementation ( ) . TransactionContext ;
226
+ txContext ? . WaitOne ( ) ;
227
+ if ( ! session . IsOpen )
228
+ continue ;
229
+
230
+ if ( txContext ? . ShouldCloseSessionOnDistributedTransactionCompleted ?? false )
226
231
{
227
- log . Error ( $ "Test case didn't close session { session . GetSessionImplementation ( ) . SessionId } , closing") ;
228
- allClosed = false ;
229
- session . Close ( ) ;
232
+ // Delayed rollback not having lock from prepare phase? Give it a chance to complete.
233
+ Thread . Sleep ( 100 ) ;
234
+ txContext . WaitOne ( ) ;
235
+ if ( ! session . IsOpen )
236
+ {
237
+ Assert . Warn ( $ "Test case had a delayed close of session { session . GetSessionImplementation ( ) . SessionId } .") ;
238
+ continue ;
239
+ }
230
240
}
241
+
242
+ log . Error ( $ "Test case didn't close session { session . GetSessionImplementation ( ) . SessionId } , closing") ;
243
+ allClosed = false ;
244
+ session . Close ( ) ;
231
245
}
232
246
233
247
return allClosed ;
You can’t perform that action at this time.
0 commit comments