Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions src/NHibernate/Async/Transaction/AdoTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,29 @@ protected virtual async Task DisposeAsync(bool isDisposing, CancellationToken ca
// know this call came through Dispose()
if (isDisposing)
{
if (trans != null)
try
{
trans.Dispose();
trans = null;
log.Debug("DbTransaction disposed.");
}
if (trans != null)
{
trans.Dispose();
trans = null;
log.Debug("DbTransaction disposed.");
}

if (IsActive && session != null)
if (IsActive && session != null)
{
// Assume we are rolled back
await (AfterTransactionCompletionAsync(false, cancellationToken)).ConfigureAwait(false);
}
// nothing for Finalizer to do - so tell the GC to ignore it
GC.SuppressFinalize(this);
}
finally
{
// Assume we are rolled back
await (AfterTransactionCompletionAsync(false, cancellationToken)).ConfigureAwait(false);
// Do not leave the object in an inconsistent state in case of disposal failure: we should assume
// the DbTransaction is either no more ongoing or unrecoverable.
begun = false;
}
// nothing for Finalizer to do - so tell the GC to ignore it
GC.SuppressFinalize(this);
}

// free unmanaged resources here
Expand Down
29 changes: 19 additions & 10 deletions src/NHibernate/Transaction/AdoTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,20 +376,29 @@ protected virtual void Dispose(bool isDisposing)
// know this call came through Dispose()
if (isDisposing)
{
if (trans != null)
try
{
trans.Dispose();
trans = null;
log.Debug("DbTransaction disposed.");
if (trans != null)
{
trans.Dispose();
trans = null;
log.Debug("DbTransaction disposed.");
}

if (IsActive && session != null)
{
// Assume we are rolled back
AfterTransactionCompletion(false);
}
// nothing for Finalizer to do - so tell the GC to ignore it
GC.SuppressFinalize(this);
}

if (IsActive && session != null)
finally
{
// Assume we are rolled back
AfterTransactionCompletion(false);
// Do not leave the object in an inconsistent state in case of disposal failure: we should assume
// the DbTransaction is either no more ongoing or unrecoverable.
begun = false;
}
// nothing for Finalizer to do - so tell the GC to ignore it
GC.SuppressFinalize(this);
}

// free unmanaged resources here
Expand Down