Skip to content

Commit

Permalink
Fix ArgumentNullException when provider is unable to open a connection (
Browse files Browse the repository at this point in the history
#2882)

Back-port of #2794
  • Loading branch information
hazzik authored Aug 4, 2021
1 parent 6ad2b3e commit d6ff0a0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/NHibernate/Async/Tool/hbm2ddl/SchemaExport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,11 @@ public async Task ExecuteAsync(Action<string> scriptAction, bool execute, bool j
{
if (connectionProvider != null)
{
connectionProvider.CloseConnection(connection);
if (connection != null)
{
connectionProvider.CloseConnection(connection);
}

connectionProvider.Dispose();
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/NHibernate/Tool/hbm2ddl/SchemaExport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,11 @@ private void InitConnectionAndExecute(Action<string> scriptAction, bool execute,
{
if (connectionProvider != null)
{
connectionProvider.CloseConnection(connection);
if (connection != null)
{
connectionProvider.CloseConnection(connection);
}

connectionProvider.Dispose();
}
}
Expand Down
2 changes: 1 addition & 1 deletion teamcity.build
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
<property name="db-service" value="MySQL57" />
<property name="nhibernate.connection.driver_class" value="NHibernate.Driver.MySqlDataDriver" />
<property name="nhibernate.dialect" value="NHibernate.Dialect.MySQL5Dialect" />
<property name="nhibernate.connection.connection_string" value="Data Source=localhost;Database=nhibernate;User ID=nhibernate;Password=nhibernate;Protocol=memory;Old Guids=True;" />
<property name="nhibernate.connection.connection_string" value="Data Source=localhost;Database=nhibernate;User ID=nhibernate;Password=nhibernate;Protocol=memory;Old Guids=True;SslMode=none;" />
</target>

<target name="setup-teamcity-sqlanywhere">
Expand Down

0 comments on commit d6ff0a0

Please sign in to comment.