Making exceptions during ITransaction.Dispose() safer

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2013-04-22 09:51:02 -07:00
parent 19f287b5b2
commit d05b9ede1a

View File

@@ -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;
}
}
}