diff --git a/Tools/packages.config b/Tools/packages.config index 01fee594627..281d376dc8d 100644 --- a/Tools/packages.config +++ b/Tools/packages.config @@ -7,6 +7,6 @@ - + diff --git a/src/NHibernate.Test/Async/Cascade/Circle/MultiPathCircleCascadeTest.cs b/src/NHibernate.Test/Async/Cascade/Circle/MultiPathCircleCascadeTest.cs index 83876eb50c7..b753abf1b54 100644 --- a/src/NHibernate.Test/Async/Cascade/Circle/MultiPathCircleCascadeTest.cs +++ b/src/NHibernate.Test/Async/Cascade/Circle/MultiPathCircleCascadeTest.cs @@ -155,6 +155,7 @@ public async Task MergeEntityWithNonNullableEntityNullAsync() await (session.MergeAsync(route, cancellationToken)); Assert.Fail("should have thrown an exception"); } + catch (OperationCanceledException) { throw; } catch (Exception ex) { Assert.That(ex, Is.TypeOf(typeof(PropertyValueException))); diff --git a/src/NHibernate.Test/Async/DebugConnectionProvider.cs b/src/NHibernate.Test/Async/DebugConnectionProvider.cs index c2a626f7475..39f4ee9d6bf 100644 --- a/src/NHibernate.Test/Async/DebugConnectionProvider.cs +++ b/src/NHibernate.Test/Async/DebugConnectionProvider.cs @@ -30,6 +30,7 @@ public override async Task GetConnectionAsync(CancellationToken ca connections.TryAdd(connection, 0); return connection; } + catch (OperationCanceledException) { throw; } catch (Exception e) { throw new HibernateException("Could not open connection to: " + ConnectionString, e); diff --git a/src/NHibernate.Test/Async/Events/Collections/Association/Bidirectional/ManyToMany/BidirectionalManyToManyBagToSetCollectionEventFixture.cs b/src/NHibernate.Test/Async/Events/Collections/Association/Bidirectional/ManyToMany/BidirectionalManyToManyBagToSetCollectionEventFixture.cs index af23e6b4c3b..5501e23fc1a 100644 --- a/src/NHibernate.Test/Async/Events/Collections/Association/Bidirectional/ManyToMany/BidirectionalManyToManyBagToSetCollectionEventFixture.cs +++ b/src/NHibernate.Test/Async/Events/Collections/Association/Bidirectional/ManyToMany/BidirectionalManyToManyBagToSetCollectionEventFixture.cs @@ -39,13 +39,13 @@ public override Task UpdateParentOneToTwoSameChildrenAsync() { Assert.Ignore("Not supported"); return Task.CompletedTask; + // This test need some more deep study if it really work in H3.2 + // because allow duplication. } catch (System.Exception ex) { return Task.FromException(ex); } - // This test need some more deep study if it really work in H3.2 - // because allow duplication. } } } \ No newline at end of file diff --git a/src/NHibernate.Test/Async/ExpressionTest/QueryByExampleTest.cs b/src/NHibernate.Test/Async/ExpressionTest/QueryByExampleTest.cs index cd1893553da..9e4036a8063 100644 --- a/src/NHibernate.Test/Async/ExpressionTest/QueryByExampleTest.cs +++ b/src/NHibernate.Test/Async/ExpressionTest/QueryByExampleTest.cs @@ -17,7 +17,6 @@ namespace NHibernate.Test.ExpressionTest { using System.Threading.Tasks; - using System.Threading; [TestFixture] public class QueryByExampleTestAsync : TestCase { @@ -150,30 +149,6 @@ public async Task TestExcludingQBEAsync() } } - private async Task InitDataAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - using (ISession s = OpenSession()) - { - Componentizable master = GetMaster("hibernate", "ORM tool", "ORM tool1"); - await (s.SaveAsync(master, cancellationToken)); - await (s.FlushAsync(cancellationToken)); - } - - using (ISession s = OpenSession()) - { - Componentizable master = GetMaster("hibernate", "open source", "open source1"); - await (s.SaveAsync(master, cancellationToken)); - await (s.FlushAsync(cancellationToken)); - } - - using (ISession s = OpenSession()) - { - Componentizable master = GetMaster("hibernate", null, null); - await (s.SaveAsync(master, cancellationToken)); - await (s.FlushAsync(cancellationToken)); - } - } - private void InitData() { using (ISession s = OpenSession()) @@ -198,16 +173,6 @@ private void InitData() } } - private async Task DeleteDataAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - using (ISession s = OpenSession()) - using (ITransaction t = s.BeginTransaction()) - { - await (s.DeleteAsync("from Componentizable", cancellationToken)); - await (t.CommitAsync(cancellationToken)); - } - } - private void DeleteData() { using (ISession s = OpenSession()) diff --git a/src/NHibernate.Test/Async/NHSpecificTest/Logs/LogsFixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/Logs/LogsFixture.cs index 1a9cdefceac..71ada7ac57e 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/Logs/LogsFixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/Logs/LogsFixture.cs @@ -156,7 +156,8 @@ public async Task WillGetSessionIdFromSessionLogsConcurrentAsync() var sessionIds = new ConcurrentDictionary(); using (var spy = new TextLogSpy("NHibernate.SQL", "%message | SessionId: %property{sessionId}")) { - await (Task.WhenAll(Enumerable.Range( 1, 12).Select( async i => + await (Task.WhenAll( + Enumerable.Range(1, 12 - 1).Select(async i => { if (i > 10) { diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH1507/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH1507/Fixture.cs index 1fb0778ed9c..48a864ef62c 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH1507/Fixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH1507/Fixture.cs @@ -16,7 +16,6 @@ namespace NHibernate.Test.NHSpecificTest.NH1507 { using System.Threading.Tasks; - using System.Threading; [TestFixture] public class FixtureAsync : BugTestCase { @@ -35,54 +34,6 @@ protected override void OnTearDown() CleanupData(); } - private async Task CreateDataAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - //Employee - var emp = new Employee - { - Address = "Zombie street", - City = "Bitonto", - PostalCode = "66666", - FirstName = "tomb", - LastName = "mutilated" - }; - - //and his related orders - var order = new Order - {OrderDate = DateTime.Now, Employee = emp, ShipAddress = "dead zone 1", ShipCountry = "Deadville"}; - - var order2 = new Order - {OrderDate = DateTime.Now, Employee = emp, ShipAddress = "dead zone 2", ShipCountry = "Deadville"}; - - //Employee with no related orders but with same PostalCode - var emp2 = new Employee - { - Address = "Gut street", - City = "Mariotto", - Country = "Arised", - PostalCode = "66666", - FirstName = "carcass", - LastName = "purulent" - }; - - //Order with no related employee but with same ShipCountry - var order3 = new Order {OrderDate = DateTime.Now, ShipAddress = "dead zone 2", ShipCountry = "Deadville"}; - - using (ISession session = OpenSession()) - { - using (ITransaction tx = session.BeginTransaction()) - { - await (session.SaveAsync(emp, cancellationToken)); - await (session.SaveAsync(emp2, cancellationToken)); - await (session.SaveAsync(order, cancellationToken)); - await (session.SaveAsync(order2, cancellationToken)); - await (session.SaveAsync(order3, cancellationToken)); - - await (tx.CommitAsync(cancellationToken)); - } - } - } - private void CreateData() { //Employee @@ -131,23 +82,6 @@ private void CreateData() } } - private async Task CleanupDataAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - using (ISession session = OpenSession()) - { - using (ITransaction tx = session.BeginTransaction()) - { - //delete empolyee and related orders - await (session.DeleteAsync("from Employee ee where ee.PostalCode = '66666'", cancellationToken)); - - //delete order not related to employee - await (session.DeleteAsync("from Order oo where oo.ShipCountry = 'Deadville'", cancellationToken)); - - await (tx.CommitAsync(cancellationToken)); - } - } - } - private void CleanupData() { using (ISession session = OpenSession()) diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH1553/MsSQL/SnapshotIsolationUpdateConflictTest.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH1553/MsSQL/SnapshotIsolationUpdateConflictTest.cs index 51b512ca1a9..ad82ceb33c0 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH1553/MsSQL/SnapshotIsolationUpdateConflictTest.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH1553/MsSQL/SnapshotIsolationUpdateConflictTest.cs @@ -159,17 +159,6 @@ protected override bool AppliesTo(ISessionFactoryImplementor factory) return factory.ConnectionProvider.Driver is SqlClientDriver; } - private async Task SetAllowSnapshotIsolationAsync(bool on, CancellationToken cancellationToken = default(CancellationToken)) - { - using (ISession session = OpenSession()) - { - var command = session.Connection.CreateCommand(); - command.CommandText = "ALTER DATABASE " + session.Connection.Database + " set allow_snapshot_isolation " - + (on ? "on" : "off"); - await (command.ExecuteNonQueryAsync(cancellationToken)); - } - } - private void SetAllowSnapshotIsolation(bool on) { using (ISession session = OpenSession()) diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH1792/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH1792/Fixture.cs index e82d4a880f2..1d5b3022887 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH1792/Fixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH1792/Fixture.cs @@ -16,7 +16,6 @@ namespace NHibernate.Test.NHSpecificTest.NH1792 { using System.Threading.Tasks; - using System.Threading; [TestFixture] public class FixtureAsync : BugTestCase { @@ -25,22 +24,6 @@ protected override void OnTearDown() DeleteAll(); } - /// - /// Deletes all the product entities from the persistence medium - /// - /// A cancellation token that can be used to cancel the work - private async Task DeleteAllAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - using (ISession session = OpenSession()) - { - using (ITransaction trans = session.BeginTransaction()) - { - await (session.DeleteAsync("from Product", cancellationToken)); - await (trans.CommitAsync(cancellationToken)); - } - } - } - /// /// Deletes all the product entities from the persistence medium /// diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH2302/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH2302/Fixture.cs index 759fe34b3e7..df16c52023c 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH2302/Fixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH2302/Fixture.cs @@ -17,7 +17,6 @@ namespace NHibernate.Test.NHSpecificTest.NH2302 { using System.Threading.Tasks; - using System.Threading; [TestFixture] public class FixtureAsync : BugTestCase { @@ -197,16 +196,6 @@ public async Task BlobWithoutLengthAsync() } } - private async Task CleanUpAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - using (ISession session = OpenSession()) - using (ITransaction tx = session.BeginTransaction()) - { - await (session.DeleteAsync("from StringLengthEntity", cancellationToken)); - await (tx.CommitAsync(cancellationToken)); - } - } - private void CleanUp() { using (ISession session = OpenSession()) diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH2583/ManualTestFixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH2583/ManualTestFixture.cs index c459727b5af..e3a1afd2f45 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH2583/ManualTestFixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH2583/ManualTestFixture.cs @@ -305,18 +305,6 @@ protected override void OnTearDown() } } - private static Task DeleteAllAsync(ISession session, CancellationToken cancellationToken = default(CancellationToken)) - { - try - { - return session.CreateQuery("delete from " + typeof(T).Name).ExecuteUpdateAsync(cancellationToken); - } - catch (Exception ex) - { - return Task.FromException(ex); - } - } - private static void DeleteAll(ISession session) { session.CreateQuery("delete from " + typeof(T).Name).ExecuteUpdate(); diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH3023/DeadlockConnectionPoolIssueTest.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH3023/DeadlockConnectionPoolIssueTest.cs index 5541da25321..91325e5a843 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH3023/DeadlockConnectionPoolIssueTest.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH3023/DeadlockConnectionPoolIssueTest.cs @@ -273,34 +273,6 @@ private static TransactionScope CreateDistributedTransactionScope() return scope; } - private async Task RunScriptAsync(string script, CancellationToken cancellationToken = default(CancellationToken)) - { - var cxnString = cfg.Properties["connection.connection_string"] + "; Pooling=No"; - // Disable connection pooling so this won't be hindered by - // problems encountered during the actual test - - string sql; - using (var reader = new StreamReader(GetType().Assembly.GetManifestResourceStream(GetType().Namespace + "." + script))) - { - sql = await (reader.ReadToEndAsync()); - } - - using (var cxn = new SqlConnection(cxnString)) - { - await (cxn.OpenAsync(cancellationToken)); - - foreach (var batch in Regex.Split(sql, @"^go\s*$", RegexOptions.IgnoreCase | RegexOptions.Multiline) - .Where(b => !string.IsNullOrEmpty(b))) - { - - using (var cmd = new System.Data.SqlClient.SqlCommand(batch, cxn)) - { - await (cmd.ExecuteNonQueryAsync(cancellationToken)); - } - } - } - } - private void RunScript(string script) { var cxnString = cfg.Properties["connection.connection_string"] + "; Pooling=No"; diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH3332/TestJoinsWithSameTable.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH3332/TestJoinsWithSameTable.cs index 937e50734ce..e9f029b6656 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH3332/TestJoinsWithSameTable.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH3332/TestJoinsWithSameTable.cs @@ -16,7 +16,6 @@ namespace NHibernate.Test.NHSpecificTest.NH3332 { using System.Threading.Tasks; - using System.Threading; [TestFixture] public class TestJoinsWithSameTableAsync : BugTestCase { @@ -84,71 +83,6 @@ from std in me.State.StateDescriptions } - private async Task CreateObjectsAsync(ISession session, CancellationToken cancellationToken = default(CancellationToken)) - { - // Create the English culture - Culture englishCulture = new Culture(); - - - englishCulture.CountryCode = "CA"; - englishCulture.LanguageCode = "en"; - - await (session.SaveOrUpdateAsync(englishCulture, cancellationToken)); - await (session.FlushAsync(cancellationToken)); - - // Create the Spanish culture - Culture spanishCulture = new Culture(); - spanishCulture.CountryCode = "ES"; - spanishCulture.LanguageCode = "es"; - - await (session.SaveOrUpdateAsync(spanishCulture, cancellationToken)); - await (session.FlushAsync(cancellationToken)); - - // Create a DataType and attach it an English description - - DataType dataType1 = new DataType(); - dataType1.Name = "int"; - - DataTypeDescription dataTypeDescription1 = new DataTypeDescription(); - - dataTypeDescription1.Culture = englishCulture; - dataTypeDescription1.DataType = dataType1; - - dataType1.DataTypeDescriptions.Add(dataTypeDescription1); - - - - // Create a State and attach it an English description and a Spanish description - - State state1 = new State(); - state1.Name = "Development"; - - StateDescription englishStateDescription = new StateDescription(); - englishStateDescription.Culture = englishCulture; - englishStateDescription.State = state1; - // englishStateDescription.Description = "Development - English"; - - state1.StateDescriptions.Add(englishStateDescription); - - StateDescription spanishStateDescription = new StateDescription(); - spanishStateDescription.Culture = spanishCulture; - spanishStateDescription.State = state1; - // spanishStateDescription.Description = "Development - Spanish"; - - state1.StateDescriptions.Add(spanishStateDescription); - - - MasterEntity masterEntity = new MasterEntity(); - - masterEntity.Name = "MasterEntity 1"; - masterEntity.State = state1; - masterEntity.DataType = dataType1; - - await (session.SaveOrUpdateAsync(masterEntity, cancellationToken)); - await (session.FlushAsync(cancellationToken)); - } - - private void CreateObjects(ISession session) { // Create the English culture diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH3620/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH3620/Fixture.cs index 466659cbe9e..076371afdfa 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH3620/Fixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH3620/Fixture.cs @@ -14,7 +14,6 @@ namespace NHibernate.Test.NHSpecificTest.NH3620 { using System.Threading.Tasks; - using System.Threading; [TestFixture] public class FixtureAsync : BugTestCase { protected override bool AppliesTo(Engine.ISessionFactoryImplementor factory) { @@ -44,16 +43,6 @@ public async Task Should_insert_two_blobs_and_a_dateAsync() } } - private async Task CleanupDataAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - using (ISession session = OpenSession()) { - using (ITransaction tx = session.BeginTransaction()) { - await (session.DeleteAsync("from TwoBlobs", cancellationToken)); - await (tx.CommitAsync(cancellationToken)); - } - } - } - private void CleanupData() { using (ISession session = OpenSession()) { using (ITransaction tx = session.BeginTransaction()) { diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH3641/TestFixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH3641/TestFixture.cs index bc267f0cf7d..164c4f7bdb4 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH3641/TestFixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH3641/TestFixture.cs @@ -15,7 +15,6 @@ namespace NHibernate.Test.NHSpecificTest.NH3641 { using System.Threading.Tasks; - using System.Threading; [TestFixture] public class TestFixtureAsync : BugTestCase { @@ -44,12 +43,6 @@ protected override void OnTearDown() } } - private static async Task DeleteAllAsync(ISession session, CancellationToken cancellationToken = default(CancellationToken)) - { - await (session.CreateQuery("delete from " + typeof(T).Name + " where ChildInterface is not null").ExecuteUpdateAsync(cancellationToken)); - await (session.CreateQuery("delete from " + typeof(T).Name).ExecuteUpdateAsync(cancellationToken)); - } - private static void DeleteAll(ISession session) { session.CreateQuery("delete from " + typeof(T).Name + " where ChildInterface is not null").ExecuteUpdate(); diff --git a/src/NHibernate.Test/Async/SystemTransactions/DistributedSystemTransactionFixture.cs b/src/NHibernate.Test/Async/SystemTransactions/DistributedSystemTransactionFixture.cs index 710ec87a28e..ca7c64e5a9d 100644 --- a/src/NHibernate.Test/Async/SystemTransactions/DistributedSystemTransactionFixture.cs +++ b/src/NHibernate.Test/Async/SystemTransactions/DistributedSystemTransactionFixture.cs @@ -156,46 +156,6 @@ public async Task CanRollbackTransactionAsync(bool explicitFlush) AssertNoPersons(); } - [Theory] - public void CanRollbackTransaction(bool explicitFlush) - { - IgnoreIfUnsupported(explicitFlush); - var tx = new TransactionScope(); - var disposeCalled = false; - try - { - using (var s = OpenSession()) - { - ForceEscalationToDistributedTx.Escalate(true); //will rollback tx - s.Save(new Person()); - - if (explicitFlush) - s.Flush(); - - tx.Complete(); - } - disposeCalled = true; - Assert.Throws(tx.Dispose, "Scope disposal has not rollback and throw."); - } - finally - { - if (!disposeCalled) - { - try - { - tx.Dispose(); - } - catch - { - // Ignore, if disposed has not been called, another exception has occurred in the try and - // we should avoid overriding it by the disposal failure. - } - } - } - - AssertNoPersons(); - } - [Theory] public async Task CanRollbackTransactionFromScopeAsync(bool explicitFlush) { @@ -246,38 +206,6 @@ public async Task RollbackOutsideNhAsync(bool explicitFlush) AssertNoPersons(); } - [Theory] - [Description("Another action inside the transaction do the rollBack outside nh-session-scope.")] - public void RollbackOutsideNh(bool explicitFlush) - { - IgnoreIfUnsupported(explicitFlush); - try - { - using (var txscope = new TransactionScope()) - { - using (var s = OpenSession()) - { - var person = new Person(); - s.Save(person); - - if (explicitFlush) - s.Flush(); - } - ForceEscalationToDistributedTx.Escalate(true); //will rollback tx - - txscope.Complete(); - } - - Assert.Fail("Scope disposal has not rollback and throw."); - } - catch (TransactionAbortedException) - { - _log.Debug("Transaction aborted."); - } - - AssertNoPersons(); - } - [Theory] [Description("rollback inside nh-session-scope should not commit save and the transaction should be aborted.")] public async Task TransactionInsertWithRollBackFromScopeAsync(bool explicitFlush) @@ -330,37 +258,6 @@ public async Task TransactionInsertWithRollBackTaskAsync(bool explicitFlush) AssertNoPersons(); } - [Theory] - [Description("rollback inside nh-session-scope should not commit save and the transaction should be aborted.")] - public void TransactionInsertWithRollBackTask(bool explicitFlush) - { - IgnoreIfUnsupported(explicitFlush); - try - { - using (var txscope = new TransactionScope()) - { - using (var s = OpenSession()) - { - var person = new Person(); - s.Save(person); - ForceEscalationToDistributedTx.Escalate(true); //will rollback tx - - if (explicitFlush) - s.Flush(); - } - txscope.Complete(); - } - - Assert.Fail("Scope disposal has not rollback and throw."); - } - catch (TransactionAbortedException) - { - _log.Debug("Transaction aborted."); - } - - AssertNoPersons(); - } - [Theory] [Description(@"Two session in two txscope (without an explicit NH transaction) @@ -459,60 +356,6 @@ public async Task TransactionInsertLoadWithRollBackTaskAsync(bool explicitFlush) } } - [Theory] - [Description(@"Two session in two txscope - (without an explicit NH transaction) - and with a rollback in the second dtc and a ForceRollback outside nh-session-scope.")] - public void TransactionInsertLoadWithRollBackTask(bool explicitFlush) - { - IgnoreIfUnsupported(explicitFlush); - object savedId; - var createdAt = DateTime.Today; - using (var txscope = new TransactionScope()) - { - using (var s = OpenSession()) - { - var person = new Person { CreatedAt = createdAt }; - savedId = s.Save(person); - - if (explicitFlush) - s.Flush(); - } - txscope.Complete(); - } - - try - { - using (var txscope = new TransactionScope()) - { - using (var s = OpenSession()) - { - var person = s.Get(savedId); - person.CreatedAt = createdAt.AddMonths(-1); - - if (explicitFlush) - s.Flush(); - } - ForceEscalationToDistributedTx.Escalate(true); - - _log.Debug("completing the tx scope"); - txscope.Complete(); - } - _log.Debug("Transaction fail."); - Assert.Fail("Expected tx abort"); - } - catch (TransactionAbortedException) - { - _log.Debug("Transaction aborted."); - } - - using (var s = OpenSession()) - using (s.BeginTransaction()) - { - Assert.AreEqual(createdAt, s.Get(savedId).CreatedAt, "Entity update was not rollback-ed."); - } - } - [Theory] public async Task CanDeleteItemInDtcAsync(bool explicitFlush) { diff --git a/src/NHibernate/Async/Action/BulkOperationCleanupAction.cs b/src/NHibernate/Async/Action/BulkOperationCleanupAction.cs index 1c2edc9c52d..899db3bc5d0 100644 --- a/src/NHibernate/Async/Action/BulkOperationCleanupAction.cs +++ b/src/NHibernate/Async/Action/BulkOperationCleanupAction.cs @@ -38,7 +38,6 @@ public Task BeforeExecutionsAsync(CancellationToken cancellationToken) { return Task.FromException(ex); } - // nothing to do } public Task ExecuteAsync(CancellationToken cancellationToken) @@ -56,7 +55,6 @@ public Task ExecuteAsync(CancellationToken cancellationToken) { return Task.FromException(ex); } - // nothing to do } private async Task EvictCollectionRegionsAsync(CancellationToken cancellationToken) diff --git a/src/NHibernate/Async/AdoNet/AbstractBatcher.cs b/src/NHibernate/Async/AdoNet/AbstractBatcher.cs index ea85ee19dc3..4d4af8461a2 100644 --- a/src/NHibernate/Async/AdoNet/AbstractBatcher.cs +++ b/src/NHibernate/Async/AdoNet/AbstractBatcher.cs @@ -123,6 +123,7 @@ public async Task ExecuteNonQueryAsync(DbCommand cmd, CancellationToken can { return await (cmd.ExecuteNonQueryAsync(cancellationToken)).ConfigureAwait(false); } + catch (OperationCanceledException) { throw; } catch (Exception e) { e.Data["actual-sql-query"] = cmd.CommandText; @@ -150,6 +151,7 @@ public virtual async Task ExecuteReaderAsync(DbCommand cmd, Cancel { reader = await (cmd.ExecuteReaderAsync(cancellationToken)).ConfigureAwait(false); } + catch (OperationCanceledException) { throw; } catch (Exception e) { e.Data["actual-sql-query"] = cmd.CommandText; diff --git a/src/NHibernate/Async/Cache/HashtableCache.cs b/src/NHibernate/Async/Cache/HashtableCache.cs index 622bb1dce75..97dbd81d308 100644 --- a/src/NHibernate/Async/Cache/HashtableCache.cs +++ b/src/NHibernate/Async/Cache/HashtableCache.cs @@ -107,7 +107,6 @@ public Task LockAsync(object key, CancellationToken cancellationToken) { return Task.FromException(ex); } - // local cache, so we use synchronization } /// @@ -126,7 +125,6 @@ public Task UnlockAsync(object key, CancellationToken cancellationToken) { return Task.FromException(ex); } - // local cache, so we use synchronization } #endregion diff --git a/src/NHibernate/Async/Cache/ReadOnlyCache.cs b/src/NHibernate/Async/Cache/ReadOnlyCache.cs index 81f58dd8c05..ebb500abc3f 100644 --- a/src/NHibernate/Async/Cache/ReadOnlyCache.cs +++ b/src/NHibernate/Async/Cache/ReadOnlyCache.cs @@ -169,7 +169,6 @@ public Task EvictAsync(CacheKey key, CancellationToken cancellationToken) { return Task.FromException(ex); } - // NOOP } /// diff --git a/src/NHibernate/Async/Cache/ReadWriteCache.cs b/src/NHibernate/Async/Cache/ReadWriteCache.cs index adc9ba8b508..69b4e366810 100644 --- a/src/NHibernate/Async/Cache/ReadWriteCache.cs +++ b/src/NHibernate/Async/Cache/ReadWriteCache.cs @@ -383,7 +383,6 @@ public Task EvictAsync(CacheKey key, CancellationToken cancellationToken) { return Task.FromException(ex); } - // NOOP } public Task UpdateAsync(CacheKey key, object value, object currentVersion, object previousVersion, CancellationToken cancellationToken) diff --git a/src/NHibernate/Async/Collection/Generic/PersistentGenericIdentifierBag.cs b/src/NHibernate/Async/Collection/Generic/PersistentGenericIdentifierBag.cs index 99eac211529..6573a8f8509 100644 --- a/src/NHibernate/Async/Collection/Generic/PersistentGenericIdentifierBag.cs +++ b/src/NHibernate/Async/Collection/Generic/PersistentGenericIdentifierBag.cs @@ -193,6 +193,7 @@ public override async Task PreInsertAsync(ICollectionPersister persister, Cancel } } } + catch (OperationCanceledException) { throw; } catch (Exception sqle) { throw new ADOException("Could not generate idbag row id.", sqle); diff --git a/src/NHibernate/Async/Connection/DriverConnectionProvider.cs b/src/NHibernate/Async/Connection/DriverConnectionProvider.cs index 1523e597d3f..4c3358a5943 100644 --- a/src/NHibernate/Async/Connection/DriverConnectionProvider.cs +++ b/src/NHibernate/Async/Connection/DriverConnectionProvider.cs @@ -39,6 +39,7 @@ public override async Task GetConnectionAsync(CancellationToken ca conn.ConnectionString = ConnectionString; await (conn.OpenAsync(cancellationToken)).ConfigureAwait(false); } + catch (OperationCanceledException) { throw; } catch (Exception) { conn.Dispose(); diff --git a/src/NHibernate/Async/Context/ThreadLocalSessionContext.cs b/src/NHibernate/Async/Context/ThreadLocalSessionContext.cs index ae76a4bccca..ac6a8bd848e 100644 --- a/src/NHibernate/Async/Context/ThreadLocalSessionContext.cs +++ b/src/NHibernate/Async/Context/ThreadLocalSessionContext.cs @@ -38,6 +38,7 @@ private static async Task CleanupAnyOrphanedSessionAsync(ISessionFactory factory { await (orphan.Transaction.RollbackAsync(cancellationToken)).ConfigureAwait(false); } + catch (OperationCanceledException) { throw; } catch (Exception ex) { log.Debug("Unable to rollback transaction for orphaned session", ex); @@ -45,6 +46,7 @@ private static async Task CleanupAnyOrphanedSessionAsync(ISessionFactory factory } orphan.Close(); } + catch (OperationCanceledException) { throw; } catch (Exception ex) { log.Debug("Unable to close orphaned session", ex); diff --git a/src/NHibernate/Async/Dialect/Lock/SelectLockingStrategy.cs b/src/NHibernate/Async/Dialect/Lock/SelectLockingStrategy.cs index 700ca82e6ad..1aaf3f93250 100644 --- a/src/NHibernate/Async/Dialect/Lock/SelectLockingStrategy.cs +++ b/src/NHibernate/Async/Dialect/Lock/SelectLockingStrategy.cs @@ -64,6 +64,7 @@ public async Task LockAsync(object id, object version, object obj, ISessionImple session.Batcher.CloseCommand(st, rs); } } + catch (OperationCanceledException) { throw; } catch (HibernateException) { // Do not call Convert on HibernateExceptions diff --git a/src/NHibernate/Async/Driver/NDataReader.cs b/src/NHibernate/Async/Driver/NDataReader.cs index da0f878d864..954ee397a1d 100644 --- a/src/NHibernate/Async/Driver/NDataReader.cs +++ b/src/NHibernate/Async/Driver/NDataReader.cs @@ -60,6 +60,7 @@ public static async Task CreateAsync(DbDataReader reader, bool isMi dataReader.results = resultList.ToArray(); } + catch (OperationCanceledException) { throw; } catch (Exception e) { throw new ADOException("There was a problem converting an DbDataReader to NDataReader", e); diff --git a/src/NHibernate/Async/Engine/Query/NativeSQLQueryPlan.cs b/src/NHibernate/Async/Engine/Query/NativeSQLQueryPlan.cs index 690fdc8af01..b4d94eb8668 100644 --- a/src/NHibernate/Async/Engine/Query/NativeSQLQueryPlan.cs +++ b/src/NHibernate/Async/Engine/Query/NativeSQLQueryPlan.cs @@ -96,6 +96,7 @@ public async Task PerformExecuteUpdateAsync(QueryParameters queryParameters } } } + catch (OperationCanceledException) { throw; } catch (HibernateException) { throw; diff --git a/src/NHibernate/Async/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs b/src/NHibernate/Async/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs index 0a963d30894..e172f974c51 100644 --- a/src/NHibernate/Async/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs +++ b/src/NHibernate/Async/Hql/Ast/ANTLR/Exec/AbstractStatementExecutor.cs @@ -114,6 +114,7 @@ protected virtual async Task DropTemporaryTableIfNecessaryAsync(IQueryable persi ps = await (session.Batcher.PrepareCommandAsync(CommandType.Text, commandText, new SqlType[0], cancellationToken)).ConfigureAwait(false); await (session.Batcher.ExecuteNonQueryAsync(ps, cancellationToken)).ConfigureAwait(false); } + catch (OperationCanceledException) { throw; } catch (Exception t) { log.Warn("unable to cleanup temporary id table after use [" + t + "]"); @@ -150,6 +151,7 @@ public async Task DoWorkAsync(DbConnection connection, DbTransaction transaction await (stmnt.ExecuteNonQueryAsync(cancellationToken)).ConfigureAwait(false); session.Factory.Settings.SqlStatementLogger.LogCommand(stmnt, FormatStyle.Ddl); } + catch (OperationCanceledException) { throw; } catch (Exception t) { log.Debug("unable to create temporary id table [" + t.Message + "]"); @@ -186,6 +188,7 @@ public async Task DoWorkAsync(DbConnection connection, DbTransaction transaction await (stmnt.ExecuteNonQueryAsync(cancellationToken)).ConfigureAwait(false); session.Factory.Settings.SqlStatementLogger.LogCommand(stmnt, FormatStyle.Ddl); } + catch (OperationCanceledException) { throw; } catch (Exception t) { log.Warn("unable to drop temporary id table after use [" + t.Message + "]"); diff --git a/src/NHibernate/Async/Id/Enhanced/TableGenerator.cs b/src/NHibernate/Async/Id/Enhanced/TableGenerator.cs index e7810ed7c5d..277068ac264 100644 --- a/src/NHibernate/Async/Id/Enhanced/TableGenerator.cs +++ b/src/NHibernate/Async/Id/Enhanced/TableGenerator.cs @@ -101,6 +101,7 @@ public override async Task DoWorkInCurrentTransactionAsync(ISessionImple result = Convert.ToInt64(selectedValue); } } + catch (OperationCanceledException) { throw; } catch (Exception ex) { log.Error("Unable to read or initialize hi value in " + TableName, ex); @@ -124,6 +125,7 @@ public override async Task DoWorkInCurrentTransactionAsync(ISessionImple updatedRows = await (updateCmd.ExecuteNonQueryAsync(cancellationToken)).ConfigureAwait(false); } } + catch (OperationCanceledException) { throw; } catch (Exception ex) { log.Error("Unable to update hi value in " + TableName, ex); diff --git a/src/NHibernate/Async/Id/Enhanced/TableStructure.cs b/src/NHibernate/Async/Id/Enhanced/TableStructure.cs index 3ffe419da73..f4876703147 100644 --- a/src/NHibernate/Async/Id/Enhanced/TableStructure.cs +++ b/src/NHibernate/Async/Id/Enhanced/TableStructure.cs @@ -56,6 +56,7 @@ public override async Task DoWorkInCurrentTransactionAsync(ISessionImple } result = Convert.ToInt64(selectedValue); } + catch (OperationCanceledException) { throw; } catch (Exception sqle) { Log.Error("could not read a hi value", sqle); @@ -77,6 +78,7 @@ public override async Task DoWorkInCurrentTransactionAsync(ISessionImple updatedRows = await (updateCmd.ExecuteNonQueryAsync(cancellationToken)).ConfigureAwait(false); } } + catch (OperationCanceledException) { throw; } catch (Exception sqle) { Log.Error("could not update hi value in: " + _tableName, sqle); diff --git a/src/NHibernate/Async/Id/IdentifierGeneratorFactory.cs b/src/NHibernate/Async/Id/IdentifierGeneratorFactory.cs index 86d91f6e4d0..d7e8724575f 100644 --- a/src/NHibernate/Async/Id/IdentifierGeneratorFactory.cs +++ b/src/NHibernate/Async/Id/IdentifierGeneratorFactory.cs @@ -72,6 +72,7 @@ public static async Task GetAsync(DbDataReader rs, IType type, ISessionI { return await (type.NullSafeGetAsync(rs, rs.GetName(0), session, null, cancellationToken)).ConfigureAwait(false); } + catch (OperationCanceledException) { throw; } catch (Exception e) { throw new IdentifierGenerationException("could not retrieve identifier value", e); diff --git a/src/NHibernate/Async/Id/NativeGuidGenerator.cs b/src/NHibernate/Async/Id/NativeGuidGenerator.cs index dbd3a068460..721a544843c 100644 --- a/src/NHibernate/Async/Id/NativeGuidGenerator.cs +++ b/src/NHibernate/Async/Id/NativeGuidGenerator.cs @@ -56,6 +56,7 @@ public async Task GenerateAsync(ISessionImplementor session, object obj, session.Batcher.CloseCommand(st, reader); } } + catch (OperationCanceledException) { throw; } catch (Exception sqle) { throw ADOExceptionHelper.Convert(session.Factory.SQLExceptionConverter, sqle, "could not retrieve GUID", sql); diff --git a/src/NHibernate/Async/Id/TableGenerator.cs b/src/NHibernate/Async/Id/TableGenerator.cs index 30853fa1211..1f342e8fb42 100644 --- a/src/NHibernate/Async/Id/TableGenerator.cs +++ b/src/NHibernate/Async/Id/TableGenerator.cs @@ -93,6 +93,7 @@ public override async Task DoWorkInCurrentTransactionAsync(ISessionImple } result = Convert.ToInt64(columnType.Get(rs, 0, session)); } + catch (OperationCanceledException) { throw; } catch (Exception e) { log.Error("could not read a hi value", e); @@ -120,6 +121,7 @@ public override async Task DoWorkInCurrentTransactionAsync(ISessionImple rows = await (ups.ExecuteNonQueryAsync(cancellationToken)).ConfigureAwait(false); } + catch (OperationCanceledException) { throw; } catch (Exception e) { log.Error("could not update hi value in: " + tableName, e); diff --git a/src/NHibernate/Async/Impl/MultiCriteriaImpl.cs b/src/NHibernate/Async/Impl/MultiCriteriaImpl.cs index 7fa5ea1175f..04db313c5ae 100644 --- a/src/NHibernate/Async/Impl/MultiCriteriaImpl.cs +++ b/src/NHibernate/Async/Impl/MultiCriteriaImpl.cs @@ -205,6 +205,7 @@ private async Task GetResultsFromDatabaseAsync(IList results, CancellationToken } } } + catch (OperationCanceledException) { throw; } catch (Exception sqle) { var message = string.Format("Failed to execute multi criteria: [{0}]", resultSetsCommand.Sql); diff --git a/src/NHibernate/Async/Impl/MultiQueryImpl.cs b/src/NHibernate/Async/Impl/MultiQueryImpl.cs index 06281206c97..1999c898cd1 100644 --- a/src/NHibernate/Async/Impl/MultiQueryImpl.cs +++ b/src/NHibernate/Async/Impl/MultiQueryImpl.cs @@ -173,6 +173,7 @@ protected async Task> DoListAsync(CancellationToken cancellationTok } } } + catch (OperationCanceledException) { throw; } catch (Exception sqle) { var message = string.Format("Failed to execute multi query: [{0}]", resultSetsCommand.Sql); diff --git a/src/NHibernate/Async/Impl/SessionImpl.cs b/src/NHibernate/Async/Impl/SessionImpl.cs index 68cc9b4d6f1..fe7fd67e39f 100644 --- a/src/NHibernate/Async/Impl/SessionImpl.cs +++ b/src/NHibernate/Async/Impl/SessionImpl.cs @@ -269,6 +269,7 @@ private async Task ListAsync(IQueryExpression queryExpression, QueryParameters q await (plan.PerformListAsync(queryParameters, this, results, cancellationToken)).ConfigureAwait(false); success = true; } + catch (OperationCanceledException) { throw; } catch (HibernateException) { // Do not call Convert on HibernateExceptions @@ -1066,6 +1067,7 @@ private async Task FilterAsync(object collection, string filter, QueryParameters await (plan.PerformListAsync(queryParameters, this, results, cancellationToken)).ConfigureAwait(false); success = true; } + catch (OperationCanceledException) { throw; } catch (HibernateException) { // Do not call Convert on HibernateExceptions @@ -1156,6 +1158,7 @@ public override async Task ListAsync(CriteriaImpl criteria, IList results, Cance } success = true; } + catch (OperationCanceledException) { throw; } catch (HibernateException) { // Do not call Convert on HibernateExceptions diff --git a/src/NHibernate/Async/Impl/StatelessSessionImpl.cs b/src/NHibernate/Async/Impl/StatelessSessionImpl.cs index 03b8bb20832..457ed3596ff 100644 --- a/src/NHibernate/Async/Impl/StatelessSessionImpl.cs +++ b/src/NHibernate/Async/Impl/StatelessSessionImpl.cs @@ -107,6 +107,7 @@ public override async Task ListAsync(IQueryExpression queryExpression, QueryPara await (plan.PerformListAsync(queryParameters, this, results, cancellationToken)).ConfigureAwait(false); success = true; } + catch (OperationCanceledException) { throw; } catch (HibernateException) { // Do not call Convert on HibernateExceptions @@ -148,6 +149,7 @@ public override async Task ListAsync(CriteriaImpl criteria, IList results, Cance } success = true; } + catch (OperationCanceledException) { throw; } catch (HibernateException) { // Do not call Convert on HibernateExceptions diff --git a/src/NHibernate/Async/Loader/Loader.cs b/src/NHibernate/Async/Loader/Loader.cs index f8a85bfebd0..71173bb3db7 100644 --- a/src/NHibernate/Async/Loader/Loader.cs +++ b/src/NHibernate/Async/Loader/Loader.cs @@ -116,6 +116,7 @@ protected async Task LoadSingleRowAsync(DbDataReader resultSet, ISession await (GetRowFromResultSetAsync(resultSet, session, queryParameters, GetLockModes(queryParameters.LockModes), null, hydratedObjects, new EntityKey[entitySpan], returnProxies, cancellationToken)).ConfigureAwait(false); } + catch (OperationCanceledException) { throw; } catch (HibernateException) { throw; // Don't call Convert on HibernateExceptions @@ -299,6 +300,7 @@ private async Task DoQueryAsync(ISessionImplementor session, QueryParamet Log.Debug(string.Format("done processing result set ({0} rows)", count)); } } + catch (OperationCanceledException) { throw; } catch (Exception e) { e.Data["actual-sql-query"] = st.CommandText; @@ -827,6 +829,7 @@ protected internal virtual async Task PrepareQueryCommandAsync(QueryP driver.RemoveUnusedCommandParameters(command, sqlString); driver.ExpandQueryParameters(command, sqlString, sqlCommand.ParameterTypes); } + catch (OperationCanceledException) { throw; } catch (HibernateException) { session.Batcher.CloseCommand(command, null); @@ -880,6 +883,7 @@ protected async Task GetResultSetAsync(DbCommand st, bool autoDisc } return rs; } + catch (OperationCanceledException) { throw; } catch (Exception sqle) { ADOExceptionReporter.LogExceptions(sqle); @@ -909,6 +913,7 @@ protected async Task LoadEntityAsync(ISessionImplementor session, object optionalIdentifier); result = await (DoQueryAndInitializeNonLazyCollectionsAsync(session, qp, false, cancellationToken)).ConfigureAwait(false); } + catch (OperationCanceledException) { throw; } catch (HibernateException) { throw; @@ -942,6 +947,7 @@ protected async Task LoadEntityAsync(ISessionImplementor session, object new QueryParameters(new IType[] { keyType, indexType }, new object[] { key, index }), false, cancellationToken)).ConfigureAwait(false); } + catch (OperationCanceledException) { throw; } catch (Exception sqle) { throw ADOExceptionHelper.Convert(_factory.SQLExceptionConverter, sqle, "could not collection element by index", @@ -976,6 +982,7 @@ protected internal async Task LoadEntityBatchAsync(ISessionImplementor se new QueryParameters(types, ids, optionalObject, optionalEntityName, optionalId), false, cancellationToken)).ConfigureAwait(false); } + catch (OperationCanceledException) { throw; } catch (HibernateException) { throw; @@ -1008,6 +1015,7 @@ public async Task LoadCollectionAsync(ISessionImplementor session, object id, IT { await (DoQueryAndInitializeNonLazyCollectionsAsync(session, new QueryParameters(new IType[] { type }, ids, ids), true, cancellationToken)).ConfigureAwait(false); } + catch (OperationCanceledException) { throw; } catch (HibernateException) { // Do not call Convert on HibernateExceptions @@ -1040,6 +1048,7 @@ public async Task LoadCollectionBatchAsync(ISessionImplementor session, object[] { await (DoQueryAndInitializeNonLazyCollectionsAsync(session, new QueryParameters(idTypes, ids, ids), true, cancellationToken)).ConfigureAwait(false); } + catch (OperationCanceledException) { throw; } catch (HibernateException) { // Do not call Convert on HibernateExceptions @@ -1069,6 +1078,7 @@ protected async Task LoadCollectionSubselectAsync(ISessionImplementor session, o new QueryParameters(parameterTypes, parameterValues, namedParameters, ids), true, cancellationToken)).ConfigureAwait(false); } + catch (OperationCanceledException) { throw; } catch (HibernateException) { // Do not call Convert on HibernateExceptions @@ -1239,6 +1249,7 @@ protected async Task DoListAsync(ISessionImplementor session, QueryParame { result = await (DoQueryAndInitializeNonLazyCollectionsAsync(session, queryParameters, true, forcedResultTransformer, cancellationToken)).ConfigureAwait(false); } + catch (OperationCanceledException) { throw; } catch (HibernateException) { // Do not call Convert on HibernateExceptions diff --git a/src/NHibernate/Async/Persister/Collection/AbstractCollectionPersister.cs b/src/NHibernate/Async/Persister/Collection/AbstractCollectionPersister.cs index 26e328dcb42..748159afe9c 100644 --- a/src/NHibernate/Async/Persister/Collection/AbstractCollectionPersister.cs +++ b/src/NHibernate/Async/Persister/Collection/AbstractCollectionPersister.cs @@ -217,6 +217,7 @@ public async Task RemoveAsync(object id, ISessionImplementor session, Cancellati expectation.VerifyOutcomeNonBatched(await (session.Batcher.ExecuteNonQueryAsync(st, cancellationToken)).ConfigureAwait(false), st); } } + catch (OperationCanceledException) { throw; } catch (Exception e) { if (useBatch) @@ -376,6 +377,7 @@ public async Task DeleteRowsAsync(IPersistentCollection collection, object id, I } count++; } + catch (OperationCanceledException) { throw; } catch (Exception e) { if (useBatch) @@ -517,6 +519,7 @@ protected async Task PerformInsertAsync(object ownerId, IPersistentColle expectation.VerifyOutcomeNonBatched(await (session.Batcher.ExecuteNonQueryAsync(st, cancellationToken)).ConfigureAwait(false), st); } } + catch (OperationCanceledException) { throw; } catch (Exception e) { if (useBatch) diff --git a/src/NHibernate/Async/Persister/Collection/BasicCollectionPersister.cs b/src/NHibernate/Async/Persister/Collection/BasicCollectionPersister.cs index 49a3a415ccd..067efbe8c78 100644 --- a/src/NHibernate/Async/Persister/Collection/BasicCollectionPersister.cs +++ b/src/NHibernate/Async/Persister/Collection/BasicCollectionPersister.cs @@ -98,6 +98,7 @@ protected override async Task DoUpdateRowsAsync(object id, IPersistentColle expectation.VerifyOutcomeNonBatched(await (session.Batcher.ExecuteNonQueryAsync(st, cancellationToken)).ConfigureAwait(false), st); } } + catch (OperationCanceledException) { throw; } catch (Exception e) { if (useBatch) diff --git a/src/NHibernate/Async/Persister/Collection/OneToManyPersister.cs b/src/NHibernate/Async/Persister/Collection/OneToManyPersister.cs index 4e431d4102e..165f9ca9756 100644 --- a/src/NHibernate/Async/Persister/Collection/OneToManyPersister.cs +++ b/src/NHibernate/Async/Persister/Collection/OneToManyPersister.cs @@ -81,6 +81,7 @@ protected override async Task DoUpdateRowsAsync(object id, IPersistentColle deleteExpectation.VerifyOutcomeNonBatched(await (session.Batcher.ExecuteNonQueryAsync(st, cancellationToken)).ConfigureAwait(false), st); } } + catch (OperationCanceledException) { throw; } catch (Exception e) { if (useBatch) @@ -146,6 +147,7 @@ protected override async Task DoUpdateRowsAsync(object id, IPersistentColle insertExpectation.VerifyOutcomeNonBatched(await (session.Batcher.ExecuteNonQueryAsync(st, cancellationToken)).ConfigureAwait(false), st); } } + catch (OperationCanceledException) { throw; } catch (Exception e) { if (useBatch) diff --git a/src/NHibernate/Async/Persister/Entity/AbstractEntityPersister.cs b/src/NHibernate/Async/Persister/Entity/AbstractEntityPersister.cs index 87772eff5b5..8350f5b6b47 100644 --- a/src/NHibernate/Async/Persister/Entity/AbstractEntityPersister.cs +++ b/src/NHibernate/Async/Persister/Entity/AbstractEntityPersister.cs @@ -288,6 +288,7 @@ protected async Task DehydrateAsync(object id, object[] fields, object rowI await (PropertyTypes[i].NullSafeSetAsync(statement, fields[i], index, includeColumns[i], session, cancellationToken)).ConfigureAwait(false); index += ArrayHelper.CountTrue(includeColumns[i]); //TODO: this is kinda slow... } + catch (OperationCanceledException) { throw; } catch (Exception ex) { throw new PropertyValueException("Error dehydrating property value for", EntityName, entityMetamodel.PropertyNames[i], ex); @@ -520,6 +521,7 @@ protected async Task InsertAsync(object id, object[] fields, bool[] notNull, int expectation.VerifyOutcomeNonBatched(await (session.Batcher.ExecuteNonQueryAsync(insertCmd, cancellationToken)).ConfigureAwait(false), insertCmd); } } + catch (OperationCanceledException) { throw; } catch (Exception e) { if (useBatch) @@ -658,6 +660,7 @@ protected async Task UpdateAsync(object id, object[] fields, object[] oldF return Check(await (session.Batcher.ExecuteNonQueryAsync(statement, cancellationToken)).ConfigureAwait(false), id, j, expectation, statement); } } + catch (OperationCanceledException) { throw; } catch (StaleStateException e) { if (useBatch) @@ -787,6 +790,7 @@ public async Task DeleteAsync(object id, object version, int j, object obj, SqlC Check(await (session.Batcher.ExecuteNonQueryAsync(statement, cancellationToken)).ConfigureAwait(false), tableId, j, expectation, statement); } } + catch (OperationCanceledException) { throw; } catch (Exception e) { if (useBatch) diff --git a/src/NHibernate/Async/Tool/hbm2ddl/SchemaExport.cs b/src/NHibernate/Async/Tool/hbm2ddl/SchemaExport.cs index c04e38dd66f..7b714124d47 100644 --- a/src/NHibernate/Async/Tool/hbm2ddl/SchemaExport.cs +++ b/src/NHibernate/Async/Tool/hbm2ddl/SchemaExport.cs @@ -172,6 +172,7 @@ private async Task ExecuteAsync(Action scriptAction, bool execute, bool await (ExecuteSqlAsync(statement, sql, cancellationToken)).ConfigureAwait(false); } } + catch (OperationCanceledException) { throw; } catch (Exception e) { log.Warn("Unsuccessful: " + sql); @@ -387,6 +388,7 @@ public async Task ExecuteAsync(Action scriptAction, bool execute, bool j await (ExecuteAsync(scriptAction, execute, justDrop, connection, fileOutput, cancellationToken)).ConfigureAwait(false); } + catch (OperationCanceledException) { throw; } catch (HibernateException) { // So that we don't wrap HibernateExceptions in HibernateExceptions diff --git a/src/NHibernate/Async/Tool/hbm2ddl/SchemaUpdate.cs b/src/NHibernate/Async/Tool/hbm2ddl/SchemaUpdate.cs index 49686df38dc..2e02124795b 100644 --- a/src/NHibernate/Async/Tool/hbm2ddl/SchemaUpdate.cs +++ b/src/NHibernate/Async/Tool/hbm2ddl/SchemaUpdate.cs @@ -98,6 +98,7 @@ public partial class SchemaUpdate await (new SchemaUpdate(cfg).ExecuteAsync(script, doUpdate, cancellationToken)).ConfigureAwait(false); } + catch (OperationCanceledException) { throw; } catch (Exception e) { log.Error("Error running schema update", e); @@ -160,6 +161,7 @@ public partial class SchemaUpdate meta = new DatabaseMetadata(connection, dialect); stmt = connection.CreateCommand(); } + catch (OperationCanceledException) { throw; } catch (Exception sqle) { exceptions.Add(sqle); @@ -188,6 +190,7 @@ public partial class SchemaUpdate await (stmt.ExecuteNonQueryAsync(cancellationToken)).ConfigureAwait(false); } } + catch (OperationCanceledException) { throw; } catch (Exception e) { exceptions.Add(e); @@ -197,6 +200,7 @@ public partial class SchemaUpdate log.Info("schema update complete"); } + catch (OperationCanceledException) { throw; } catch (Exception e) { exceptions.Add(e); diff --git a/src/NHibernate/Async/Tool/hbm2ddl/SchemaValidator.cs b/src/NHibernate/Async/Tool/hbm2ddl/SchemaValidator.cs index 78b684876c9..5c5d607a7ff 100644 --- a/src/NHibernate/Async/Tool/hbm2ddl/SchemaValidator.cs +++ b/src/NHibernate/Async/Tool/hbm2ddl/SchemaValidator.cs @@ -66,6 +66,7 @@ public partial class SchemaValidator */ await (new SchemaValidator(cfg).ValidateAsync(cancellationToken)).ConfigureAwait(false); } + catch (OperationCanceledException) { throw; } catch (Exception e) { log.Error("Error running schema update", e); @@ -88,6 +89,7 @@ public partial class SchemaValidator var connection = connectionHelper.Connection; meta = new DatabaseMetadata(connection, dialect, false); } + catch (OperationCanceledException) { throw; } catch (Exception sqle) { log.Error("could not get database metadata", sqle); @@ -95,6 +97,7 @@ public partial class SchemaValidator } configuration.ValidateSchema(dialect, meta); } + catch (OperationCanceledException) { throw; } catch (Exception e) { log.Error("could not complete schema validation", e); diff --git a/src/NHibernate/Async/Transaction/AdoTransaction.cs b/src/NHibernate/Async/Transaction/AdoTransaction.cs index 77156a210b6..46315e50196 100644 --- a/src/NHibernate/Async/Transaction/AdoTransaction.cs +++ b/src/NHibernate/Async/Transaction/AdoTransaction.cs @@ -70,6 +70,7 @@ private async Task AfterTransactionCompletionAsync(bool successful, Cancellation await (AfterTransactionCompletionAsync(true, cancellationToken)).ConfigureAwait(false); Dispose(); } + catch (OperationCanceledException) { throw; } catch (HibernateException e) { log.Error("Commit failed", e); diff --git a/src/NHibernate/Async/Type/CollectionType.cs b/src/NHibernate/Async/Type/CollectionType.cs index c1f9283f4cc..eaf545a80ef 100644 --- a/src/NHibernate/Async/Type/CollectionType.cs +++ b/src/NHibernate/Async/Type/CollectionType.cs @@ -62,7 +62,6 @@ public override Task NullSafeSetAsync(DbCommand st, object value, int index, boo { return Task.FromException(ex); } - // NOOP } public override Task NullSafeSetAsync(DbCommand cmd, object value, int index, ISessionImplementor session, CancellationToken cancellationToken) diff --git a/src/NHibernate/Async/Type/EntityType.cs b/src/NHibernate/Async/Type/EntityType.cs index 6e0e345b1bc..e5a25b9043c 100644 --- a/src/NHibernate/Async/Type/EntityType.cs +++ b/src/NHibernate/Async/Type/EntityType.cs @@ -236,6 +236,7 @@ public async Task LoadByUniqueKeyAsync(string entityName, string uniqueK } return result == null ? null : persistenceContext.ProxyFor(result); } + catch (OperationCanceledException) { throw; } catch (HibernateException) { // Do not call Convert on HibernateExceptions diff --git a/src/NHibernate/Async/Type/OneToOneType.cs b/src/NHibernate/Async/Type/OneToOneType.cs index 524e2ac7200..1977c5c8b95 100644 --- a/src/NHibernate/Async/Type/OneToOneType.cs +++ b/src/NHibernate/Async/Type/OneToOneType.cs @@ -37,7 +37,6 @@ public override Task NullSafeSetAsync(DbCommand st, object value, int index, boo { return Task.FromException(ex); } - //nothing to do } public override Task NullSafeSetAsync(DbCommand cmd, object value, int index, ISessionImplementor session, CancellationToken cancellationToken) @@ -55,7 +54,6 @@ public override Task NullSafeSetAsync(DbCommand cmd, object value, int index, IS { return Task.FromException(ex); } - //nothing to do } public override Task IsDirtyAsync(object old, object current, ISessionImplementor session, CancellationToken cancellationToken)