Skip to content

Commit df292f1

Browse files
Set the rolledBack flag when disposing active transactions
1 parent 97f283d commit df292f1

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/NHibernate/Async/Transaction/AdoTransaction.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,12 @@ protected virtual async Task DisposeAsync(bool isDisposing, CancellationToken ca
177177
log.Debug("DbTransaction disposed.");
178178
}
179179

180-
if (IsActive && session != null)
180+
if (IsActive)
181181
{
182182
// Assume we are rolled back
183-
await (AfterTransactionCompletionAsync(false, cancellationToken)).ConfigureAwait(false);
183+
rolledBack = true;
184+
if (session != null)
185+
await (AfterTransactionCompletionAsync(false, cancellationToken)).ConfigureAwait(false);
184186
}
185187
// nothing for Finalizer to do - so tell the GC to ignore it
186188
GC.SuppressFinalize(this);

src/NHibernate/Transaction/AdoTransaction.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,12 @@ protected virtual void Dispose(bool isDisposing)
383383
log.Debug("DbTransaction disposed.");
384384
}
385385

386-
if (IsActive && session != null)
386+
if (IsActive)
387387
{
388388
// Assume we are rolled back
389-
AfterTransactionCompletion(false);
389+
rolledBack = true;
390+
if (session != null)
391+
AfterTransactionCompletion(false);
390392
}
391393
// nothing for Finalizer to do - so tell the GC to ignore it
392394
GC.SuppressFinalize(this);

0 commit comments

Comments
 (0)