mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Making exceptions during ITransaction.Dispose() safer
--HG-- branch : 1.x
This commit is contained in:
@@ -66,19 +66,26 @@ namespace Orchard.Data {
|
||||
|
||||
void IDisposable.Dispose() {
|
||||
if (_transaction != null) {
|
||||
if (!_cancelled) {
|
||||
Logger.Debug("Marking transaction as complete");
|
||||
_transaction.Commit();
|
||||
}
|
||||
else {
|
||||
Logger.Debug("Reverting operations from transaction");
|
||||
_transaction.Rollback();
|
||||
}
|
||||
try {
|
||||
if (!_cancelled) {
|
||||
Logger.Debug("Marking transaction as complete");
|
||||
_transaction.Commit();
|
||||
}
|
||||
else {
|
||||
Logger.Debug("Reverting operations from transaction");
|
||||
_transaction.Rollback();
|
||||
}
|
||||
|
||||
_transaction.Dispose();
|
||||
Logger.Debug("Transaction disposed");
|
||||
|
||||
_cancelled = false;
|
||||
_transaction.Dispose();
|
||||
Logger.Debug("Transaction disposed");
|
||||
}
|
||||
catch (Exception e) {
|
||||
Logger.Error(e, "Error while disposing the transaction.");
|
||||
}
|
||||
finally {
|
||||
_transaction = null;
|
||||
_cancelled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user