Skip to content

Commit 90da35f

Browse files
lewingMihaZupankirankumarkolli
authored
.NET9: Fixes WebAssembly or browser scenarios by conditionally setting the ConnectionLimit (#5049)
# Pull Request Template ## Description Don't use ServicePoint at all on Browser. in net9.0 all of [ServicePoint throws PlatformNotSupported](dotnet/runtime#113174) so don't attempt to use it there. ## Type of change Please delete options that are not relevant. - [] Bug fix (non-breaking change which fixes an issue) - [] New feature (non-breaking change which adds functionality) - [] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [] This change requires a documentation update ## Closing issues closes: #5029 --------- Co-authored-by: Miha Zupan <[email protected]> Co-authored-by: Kiran Kumar Kolli <[email protected]>
1 parent 5cf1314 commit 90da35f

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Microsoft.Azure.Cosmos/src/Routing/LocationCache.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -859,8 +859,11 @@ internal bool CanUseMultipleWriteLocations()
859859
private void SetServicePointConnectionLimit(Uri endpoint)
860860
{
861861
#if !NETSTANDARD16
862-
ServicePointAccessor servicePoint = ServicePointAccessor.FindServicePoint(endpoint);
863-
servicePoint.ConnectionLimit = this.connectionLimit;
862+
if (ServicePointAccessor.IsSupported)
863+
{
864+
ServicePointAccessor servicePoint = ServicePointAccessor.FindServicePoint(endpoint);
865+
servicePoint.ConnectionLimit = this.connectionLimit;
866+
}
864867
#endif
865868
}
866869

Microsoft.Azure.Cosmos/src/Util/ServicePointAccessor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//------------------------------------------------------------
1+
//------------------------------------------------------------
22
// Copyright (c) Microsoft Corporation. All rights reserved.
33
//------------------------------------------------------------
44

@@ -15,7 +15,7 @@ namespace Microsoft.Azure.Cosmos
1515
internal class ServicePointAccessor
1616
{
1717
// WebAssembly detection
18-
private static readonly bool IsBrowser = RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")) || RuntimeInformation.IsOSPlatform(OSPlatform.Create("WEBASSEMBLY"));
18+
public static readonly bool IsSupported = !(RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")) || RuntimeInformation.IsOSPlatform(OSPlatform.Create("WEBASSEMBLY")));
1919

2020
private readonly ServicePoint servicePoint;
2121

@@ -54,7 +54,7 @@ private void TryDisableUseNagleAlgorithm()
5454

5555
private void TrySetConnectionLimit(int connectionLimit)
5656
{
57-
if (ServicePointAccessor.IsBrowser)
57+
if (!ServicePointAccessor.IsSupported)
5858
{
5959
// Workaround for WebAssembly.
6060
// WebAssembly currently throws a SynchronizationLockException and not a PlatformNotSupportedException.

0 commit comments

Comments
 (0)