Skip to content

Commit

Permalink
fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-knozderko committed Aug 2, 2024
1 parent 28ac6f7 commit e18d8eb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
4 changes: 3 additions & 1 deletion Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2284,7 +2284,9 @@ public void TestOpenAsyncThrowExceptionWhenConnectToUnreachableHost()
var thrown = Assert.Throws<AggregateException>(() => connection.OpenAsync().Wait());

// assert
SnowflakeDbExceptionAssert.HasErrorCode(thrown.InnerException, SFError.INTERNAL_ERROR);
Assert.IsTrue(thrown.InnerException is TaskCanceledException || thrown.InnerException is SnowflakeDbException);
if (thrown.InnerException is SnowflakeDbException)
SnowflakeDbExceptionAssert.HasErrorCode(thrown.InnerException, SFError.INTERNAL_ERROR);
Assert.AreEqual(ConnectionState.Closed, connection.State);
}
}
Expand Down
17 changes: 8 additions & 9 deletions Snowflake.Data/Core/HttpUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using System.Web;
using System.Security.Authentication;
using System.Linq;
using Snowflake.Data.Client;
using Snowflake.Data.Core.Authenticator;

namespace Snowflake.Data.Core
Expand Down Expand Up @@ -88,7 +87,7 @@ public sealed class HttpUtil

private HttpUtil()
{
// This value is used by AWS SDK and can cause deadlock,
// This value is used by AWS SDK and can cause deadlock,
// so we need to increase the default value of 2
// See: https://github.com/aws/aws-sdk-net/issues/152
ServicePointManager.DefaultConnectionLimit = 50;
Expand Down Expand Up @@ -182,15 +181,15 @@ internal HttpMessageHandler SetupCustomHttpHandler(HttpClientConfig config)
{
// Get the original entry
entry = bypassList[i].Trim();
// . -> [.] because . means any char
// . -> [.] because . means any char
entry = entry.Replace(".", "[.]");
// * -> .* because * is a quantifier and need a char or group to apply to
entry = entry.Replace("*", ".*");

entry = entry.StartsWith("^") ? entry : $"^{entry}";

entry = entry.EndsWith("$") ? entry : $"{entry}$";

// Replace with the valid entry syntax
bypassList[i] = entry;

Expand Down Expand Up @@ -374,6 +373,7 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage

while (true)
{

try
{
childCts = null;
Expand All @@ -384,7 +384,7 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
if (httpTimeout.Ticks == 0)
childCts.Cancel();
else
childCts.CancelAfter(httpTimeout);
childCts.CancelAfter(httpTimeout);
}
response = await base.SendAsync(requestMessage, childCts == null ?
cancellationToken : childCts.Token).ConfigureAwait(false);
Expand Down Expand Up @@ -454,8 +454,7 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
{
return response;
}
throw new SnowflakeDbException(new OperationCanceledException($"http request failed and max retry {maxRetryCount} reached"),
SFError.INTERNAL_ERROR, "Unable to connect");
throw new OperationCanceledException($"http request failed and max retry {maxRetryCount} reached");
}

// Disposing of the response if not null now that we don't need it anymore
Expand Down

0 comments on commit e18d8eb

Please sign in to comment.