Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion Tools/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<package id="NUnit.Extension.NUnitV2ResultWriter" version="3.6.0" targetFramework="net461" />
<package id="NUnit.Extension.TeamCityEventListener" version="1.0.2" targetFramework="net461" />
<package id="NUnit.Extension.VSProjectLoader" version="3.6.0" targetFramework="net461" />
<package id="CSharpAsyncGenerator.CommandLine" version="0.8.2.1" targetFramework="net461" />
<package id="CSharpAsyncGenerator.CommandLine" version="0.8.2.2" targetFramework="net461" />
<package id="vswhere" version="2.1.4" targetFramework="net461" />
<package id="gitreleasemanager" version="0.7.0" targetFramework="net461" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down
1 change: 1 addition & 0 deletions src/NHibernate.Test/Async/DebugConnectionProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public override async Task<DbConnection> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,17 @@ private void SavePerson(Person p)
/// Tests, that NHibernate detects the update conflict and returns a StaleObjectStateException as expected.
/// This behaviour is part of the standard NHibernate feature set.
/// </summary>
/// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
[Test]
public async Task UpdateConflictDetectedByNHAsync()
public async Task UpdateConflictDetectedByNHAsync(CancellationToken cancellationToken = default(CancellationToken))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maca88 that's strange

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I overlooked this change. I've released version 0.8.2.3 which doesn't generate it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again @maca88, but these changes are still there with 0.8.2.3.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to regenerate the code twice before releasing and the change was never there. Then I remembered that this issue occurred randomly depending on the order of the methods being analyzed, which was discovered and fixed when #86 was done. I've ported the fix and released it in 0.8.2.4. Again, sorry for the confusion.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No trouble, do not be sorry, it is already great you take the time to back-port things to old versions.

{
Person p1 = await (LoadPersonAsync());
Person p2 = await (LoadPersonAsync());
Person p1 = await (LoadPersonAsync(cancellationToken));
Person p2 = await (LoadPersonAsync(cancellationToken));

p1.IdentificationNumber++;
p2.IdentificationNumber += 2;

await (SavePersonAsync(p1));
await (SavePersonAsync(p1, cancellationToken));
Assert.That(p1.Version, Is.EqualTo(person.Version + 1));

var expectedException = Sfi.Settings.IsBatchVersionedDataEnabled
Expand All @@ -95,7 +96,7 @@ public async Task UpdateConflictDetectedByNHAsync()
.And.Property("EntityName").EqualTo(typeof(Person).FullName)
.And.Property("Identifier").EqualTo(p2.Id);

Assert.That(() => SavePersonAsync(p2), expectedException);
Assert.That(() => SavePersonAsync(p2, cancellationToken), expectedException);
}

/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/NHibernate/Async/AdoNet/AbstractBatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public async Task<int> 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;
Expand Down Expand Up @@ -150,6 +151,7 @@ public virtual async Task<DbDataReader> ExecuteReaderAsync(DbCommand cmd, Cancel
{
reader = await (cmd.ExecuteReaderAsync(cancellationToken)).ConfigureAwait(false);
}
catch (OperationCanceledException) { throw; }
catch (Exception e)
{
e.Data["actual-sql-query"] = cmd.CommandText;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public override async Task<DbConnection> GetConnectionAsync(CancellationToken ca
conn.ConnectionString = ConnectionString;
await (conn.OpenAsync(cancellationToken)).ConfigureAwait(false);
}
catch (OperationCanceledException) { throw; }
catch (Exception)
{
conn.Dispose();
Expand Down
2 changes: 2 additions & 0 deletions src/NHibernate/Async/Context/ThreadLocalSessionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ private static async Task CleanupAnyOrphanedSessionAsync(ISessionFactory factory
{
await (orphan.Transaction.RollbackAsync(cancellationToken)).ConfigureAwait(false);
}
catch (OperationCanceledException) { throw; }
catch (Exception ex)
{
log.Debug(ex, "Unable to rollback transaction for orphaned session");
}
}
orphan.Close();
}
catch (OperationCanceledException) { throw; }
catch (Exception ex)
{
log.Debug(ex, "Unable to close orphaned session");
Expand Down
1 change: 1 addition & 0 deletions src/NHibernate/Async/Dialect/Lock/SelectLockingStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/NHibernate/Async/Driver/NDataReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public static async Task<NDataReader> 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);
Expand Down
1 change: 1 addition & 0 deletions src/NHibernate/Async/Engine/Query/NativeSQLQueryPlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public async Task<int> PerformExecuteUpdateAsync(QueryParameters queryParameters
}
}
}
catch (OperationCanceledException) { throw; }
catch (HibernateException)
{
throw;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ protected virtual async Task DropTemporaryTableIfNecessaryAsync(IQueryable persi
ps = await (session.Batcher.PrepareCommandAsync(CommandType.Text, commandText, Array.Empty<SqlType>(), cancellationToken)).ConfigureAwait(false);
await (session.Batcher.ExecuteNonQueryAsync(ps, cancellationToken)).ConfigureAwait(false);
}
catch (OperationCanceledException) { throw; }
catch (Exception t)
{
log.Warn(t, "unable to cleanup temporary id table after use [{0}]", t);
Expand Down Expand Up @@ -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(t, "unable to create temporary id table [{0}]", t.Message);
Expand Down Expand Up @@ -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 [{0}]", t.Message);
Expand Down
2 changes: 2 additions & 0 deletions src/NHibernate/Async/Id/Enhanced/TableGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public override async Task<object> DoWorkInCurrentTransactionAsync(ISessionImple
result = Convert.ToInt64(selectedValue);
}
}
catch (OperationCanceledException) { throw; }
catch (Exception ex)
{
log.Error(ex, "Unable to read or initialize hi value in {0}", TableName);
Expand All @@ -124,6 +125,7 @@ public override async Task<object> DoWorkInCurrentTransactionAsync(ISessionImple
updatedRows = await (updateCmd.ExecuteNonQueryAsync(cancellationToken)).ConfigureAwait(false);
}
}
catch (OperationCanceledException) { throw; }
catch (Exception ex)
{
log.Error(ex, "Unable to update hi value in {0}", TableName);
Expand Down
2 changes: 2 additions & 0 deletions src/NHibernate/Async/Id/Enhanced/TableStructure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public override async Task<object> DoWorkInCurrentTransactionAsync(ISessionImple
}
result = Convert.ToInt64(selectedValue);
}
catch (OperationCanceledException) { throw; }
catch (Exception sqle)
{
Log.Error(sqle, "could not read a hi value");
Expand All @@ -76,6 +77,7 @@ public override async Task<object> DoWorkInCurrentTransactionAsync(ISessionImple
updatedRows = await (updateCmd.ExecuteNonQueryAsync(cancellationToken)).ConfigureAwait(false);
}
}
catch (OperationCanceledException) { throw; }
catch (Exception sqle)
{
Log.Error(sqle, "could not update hi value in: {0}", _tableName);
Expand Down
1 change: 1 addition & 0 deletions src/NHibernate/Async/Id/IdentifierGeneratorFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public static async Task<object> 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);
Expand Down
1 change: 1 addition & 0 deletions src/NHibernate/Async/Id/NativeGuidGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public async Task<object> 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);
Expand Down
2 changes: 2 additions & 0 deletions src/NHibernate/Async/Id/TableGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public override async Task<object> DoWorkInCurrentTransactionAsync(ISessionImple
}
result = Convert.ToInt64(columnType.Get(rs, 0, session));
}
catch (OperationCanceledException) { throw; }
catch (Exception e)
{
log.Error(e, "could not read a hi value");
Expand Down Expand Up @@ -114,6 +115,7 @@ public override async Task<object> DoWorkInCurrentTransactionAsync(ISessionImple

rows = await (ups.ExecuteNonQueryAsync(cancellationToken)).ConfigureAwait(false);
}
catch (OperationCanceledException) { throw; }
catch (Exception e)
{
log.Error(e, "could not update hi value in: {0}", tableName);
Expand Down
1 change: 1 addition & 0 deletions src/NHibernate/Async/Impl/MultiCriteriaImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ private async Task GetResultsFromDatabaseAsync(IList results, CancellationToken
}
}
}
catch (OperationCanceledException) { throw; }
catch (Exception sqle)
{
log.Error(sqle, "Failed to execute multi criteria: [{0}]", resultSetsCommand.Sql);
Expand Down
1 change: 1 addition & 0 deletions src/NHibernate/Async/Impl/MultiQueryImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ protected async Task<List<object>> DoListAsync(CancellationToken cancellationTok
}
}
}
catch (OperationCanceledException) { throw; }
catch (Exception sqle)
{
log.Error(sqle, "Failed to execute multi query: [{0}]", resultSetsCommand.Sql);
Expand Down
3 changes: 3 additions & 0 deletions src/NHibernate/Async/Impl/SessionImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,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
Expand Down Expand Up @@ -1065,6 +1066,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
Expand Down Expand Up @@ -1155,6 +1157,7 @@ public override async Task ListAsync(CriteriaImpl criteria, IList results, Cance
}
success = true;
}
catch (OperationCanceledException) { throw; }
catch (HibernateException)
{
// Do not call Convert on HibernateExceptions
Expand Down
2 changes: 2 additions & 0 deletions src/NHibernate/Async/Impl/StatelessSessionImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,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
Expand Down Expand Up @@ -145,6 +146,7 @@ public override async Task ListAsync(CriteriaImpl criteria, IList results, Cance
}
success = true;
}
catch (OperationCanceledException) { throw; }
catch (HibernateException)
{
// Do not call Convert on HibernateExceptions
Expand Down
11 changes: 11 additions & 0 deletions src/NHibernate/Async/Loader/Loader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ protected async Task<object> 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
Expand Down Expand Up @@ -298,6 +299,7 @@ private async Task<IList> DoQueryAsync(ISessionImplementor session, QueryParamet
Log.Debug("done processing result set ({0} rows)", count);
}
}
catch (OperationCanceledException) { throw; }
catch (Exception e)
{
e.Data["actual-sql-query"] = st.CommandText;
Expand Down Expand Up @@ -812,6 +814,7 @@ protected internal virtual async Task<DbCommand> PrepareQueryCommandAsync(QueryP
driver.RemoveUnusedCommandParameters(command, sqlString);
driver.ExpandQueryParameters(command, sqlString, sqlCommand.ParameterTypes);
}
catch (OperationCanceledException) { throw; }
catch (HibernateException)
{
session.Batcher.CloseCommand(command, null);
Expand Down Expand Up @@ -893,6 +896,7 @@ protected async Task<DbDataReader> GetResultSetAsync(
}
return rs;
}
catch (OperationCanceledException) { throw; }
catch (Exception sqle)
{
ADOExceptionReporter.LogExceptions(sqle);
Expand Down Expand Up @@ -922,6 +926,7 @@ protected async Task<IList> LoadEntityAsync(ISessionImplementor session, object
optionalIdentifier);
result = await (DoQueryAndInitializeNonLazyCollectionsAsync(session, qp, false, cancellationToken)).ConfigureAwait(false);
}
catch (OperationCanceledException) { throw; }
catch (HibernateException)
{
throw;
Expand Down Expand Up @@ -955,6 +960,7 @@ protected async Task<IList> 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",
Expand Down Expand Up @@ -989,6 +995,7 @@ protected internal async Task<IList> LoadEntityBatchAsync(ISessionImplementor se
new QueryParameters(types, ids, optionalObject, optionalEntityName,
optionalId), false, cancellationToken)).ConfigureAwait(false);
}
catch (OperationCanceledException) { throw; }
catch (HibernateException)
{
throw;
Expand Down Expand Up @@ -1021,6 +1028,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
Expand Down Expand Up @@ -1053,6 +1061,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
Expand Down Expand Up @@ -1082,6 +1091,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
Expand Down Expand Up @@ -1283,6 +1293,7 @@ protected async Task<IList> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -376,6 +377,7 @@ public async Task DeleteRowsAsync(IPersistentCollection collection, object id, I
}
count++;
}
catch (OperationCanceledException) { throw; }
catch (Exception e)
{
if (useBatch)
Expand Down Expand Up @@ -517,6 +519,7 @@ protected async Task<object> PerformInsertAsync(object ownerId, IPersistentColle
expectation.VerifyOutcomeNonBatched(await (session.Batcher.ExecuteNonQueryAsync(st, cancellationToken)).ConfigureAwait(false), st);
}
}
catch (OperationCanceledException) { throw; }
catch (Exception e)
{
if (useBatch)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ protected override async Task<int> DoUpdateRowsAsync(object id, IPersistentColle
expectation.VerifyOutcomeNonBatched(await (session.Batcher.ExecuteNonQueryAsync(st, cancellationToken)).ConfigureAwait(false), st);
}
}
catch (OperationCanceledException) { throw; }
catch (Exception e)
{
if (useBatch)
Expand Down
Loading