diff --git a/README.md b/README.md index 38c884360..15fac13e4 100644 --- a/README.md +++ b/README.md @@ -670,7 +670,7 @@ CancellationTokenSource cancellationTokenSource = new CancellationTokenSource() Evict the Connection -------------------- -For the open connection, call the `PreventFromReturningToPool()` to make the connection not return to the pool. +For the open connection, call the `PreventPooling()` to make the connection not return to the pool. The busy sessions counter will be decreased when the connection is closed. Logging diff --git a/Snowflake.Data.Tests/IntegrationTests/ConnectionMultiplePoolsAsyncIT.cs b/Snowflake.Data.Tests/IntegrationTests/ConnectionMultiplePoolsAsyncIT.cs index 2d46ddc7a..05e05ebbc 100644 --- a/Snowflake.Data.Tests/IntegrationTests/ConnectionMultiplePoolsAsyncIT.cs +++ b/Snowflake.Data.Tests/IntegrationTests/ConnectionMultiplePoolsAsyncIT.cs @@ -60,7 +60,7 @@ public async Task TestPreventConnectionFromReturningToPool() Assert.AreEqual(1, pool.GetCurrentPoolSize()); // act - connection.PreventFromReturningToPool(); + connection.PreventPooling(); await connection.CloseAsync(CancellationToken.None).ConfigureAwait(false); // assert diff --git a/Snowflake.Data.Tests/IntegrationTests/ConnectionMultiplePoolsIT.cs b/Snowflake.Data.Tests/IntegrationTests/ConnectionMultiplePoolsIT.cs index 931ef5c9b..9adfc6b4a 100644 --- a/Snowflake.Data.Tests/IntegrationTests/ConnectionMultiplePoolsIT.cs +++ b/Snowflake.Data.Tests/IntegrationTests/ConnectionMultiplePoolsIT.cs @@ -387,7 +387,7 @@ public void TestPreventConnectionFromReturningToPool() Assert.AreEqual(1, pool.GetCurrentPoolSize()); // act - connection.PreventFromReturningToPool(); + connection.PreventPooling(); connection.Close(); // assert diff --git a/Snowflake.Data.Tests/IntegrationTests/ConnectionPoolCommonIT.cs b/Snowflake.Data.Tests/IntegrationTests/ConnectionPoolCommonIT.cs index d0851c37b..ab55a9e35 100644 --- a/Snowflake.Data.Tests/IntegrationTests/ConnectionPoolCommonIT.cs +++ b/Snowflake.Data.Tests/IntegrationTests/ConnectionPoolCommonIT.cs @@ -116,7 +116,7 @@ public void TestFailWhenPreventingFromReturningToPoolNotOpenedConnection() var connection = new SnowflakeDbConnection(ConnectionString); // act - var thrown = Assert.Throws(() => connection.PreventFromReturningToPool()); + var thrown = Assert.Throws(() => connection.PreventPooling()); // assert Assert.That(thrown.Message, Does.Contain("Connection is not ready to prevent its session from returning to the pool")); diff --git a/Snowflake.Data.Tests/IntegrationTests/ConnectionSinglePoolCacheIT.cs b/Snowflake.Data.Tests/IntegrationTests/ConnectionSinglePoolCacheIT.cs index 1d751bfc5..3ec344f63 100644 --- a/Snowflake.Data.Tests/IntegrationTests/ConnectionSinglePoolCacheIT.cs +++ b/Snowflake.Data.Tests/IntegrationTests/ConnectionSinglePoolCacheIT.cs @@ -312,7 +312,7 @@ public void TestPreventConnectionFromReturningToPool() Assert.AreEqual(0, pool.GetCurrentPoolSize()); // act - connection.PreventFromReturningToPool(); + connection.PreventPooling(); connection.Close(); // assert diff --git a/Snowflake.Data/Client/SnowflakeDbConnection.cs b/Snowflake.Data/Client/SnowflakeDbConnection.cs index 2abaff111..1727f25e6 100755 --- a/Snowflake.Data/Client/SnowflakeDbConnection.cs +++ b/Snowflake.Data/Client/SnowflakeDbConnection.cs @@ -106,11 +106,11 @@ public override string DataSource public override ConnectionState State => _connectionState; internal SnowflakeDbTransaction ExplicitTransaction { get; set; } // tracks only explicit transaction operations - public void PreventFromReturningToPool() + public void PreventPooling() { if (SfSession == null) { - throw new Exception("Connection is not ready to prevent its session from returning to the pool"); + throw new Exception("Session not yet created for this connection. Unable to prevent the session from pooling"); } SfSession.SetPooling(false); } @@ -187,7 +187,7 @@ public override void Close() } _connectionState = ConnectionState.Closed; } - + #if NETCOREAPP3_0_OR_GREATER // CloseAsync was added to IDbConnection as part of .NET Standard 2.1, first supported by .NET Core 3.0. // Adding an override for CloseAsync will prevent the need for casting to SnowflakeDbConnection to call CloseAsync(CancellationToken).