diff --git a/sdk/core/Azure.Core/CHANGELOG.md b/sdk/core/Azure.Core/CHANGELOG.md index cead36ec0579..6b6944a6716a 100644 --- a/sdk/core/Azure.Core/CHANGELOG.md +++ b/sdk/core/Azure.Core/CHANGELOG.md @@ -10,6 +10,7 @@ ### Fixed +- Fixed `NotSupportedException` when running in Unity. ## 1.16.0 (2021-06-30) diff --git a/sdk/core/Azure.Core/src/Pipeline/ServicePointHelpers.cs b/sdk/core/Azure.Core/src/Pipeline/ServicePointHelpers.cs index 7b062ab698ac..5cb0215f81db 100644 --- a/sdk/core/Azure.Core/src/Pipeline/ServicePointHelpers.cs +++ b/sdk/core/Azure.Core/src/Pipeline/ServicePointHelpers.cs @@ -57,15 +57,17 @@ public static void SetLimits(HttpMessageHandler messageHandler) return; } - switch (messageHandler) + try { - case HttpClientHandler httpClientHandler: - // Only change when the default runtime limit is used - if (httpClientHandler.MaxConnectionsPerServer == RuntimeDefaultConnectionLimit) - { - httpClientHandler.MaxConnectionsPerServer = IncreasedConnectionLimit; - } - break; + switch (messageHandler) + { + case HttpClientHandler httpClientHandler: + // Only change when the default runtime limit is used + if (httpClientHandler.MaxConnectionsPerServer == RuntimeDefaultConnectionLimit) + { + httpClientHandler.MaxConnectionsPerServer = IncreasedConnectionLimit; + } + break; #if NETCOREAPP case SocketsHttpHandler socketsHttpHandler: if (socketsHttpHandler.MaxConnectionsPerServer == RuntimeDefaultConnectionLimit) @@ -78,9 +80,15 @@ public static void SetLimits(HttpMessageHandler messageHandler) } break; #endif - default: - Debug.Assert(false, "Unknown handler type"); - break; + default: + Debug.Assert(false, "Unknown handler type"); + break; + } + } + catch (NotSupportedException) + { + // Some platforms might throw NotSupportedException + // when accessing handler options } } }