Skip to content

Commit dc00a2a

Browse files
committed
fix
1 parent 606be6a commit dc00a2a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/SignalR/server/Core/src/HubOptionsSetup`T.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System.Collections.Generic;
5+
using Microsoft.AspNetCore.SignalR.Protocol;
56
using Microsoft.Extensions.Options;
67

78
namespace Microsoft.AspNetCore.SignalR
@@ -16,6 +17,7 @@ public HubOptionsSetup(IOptions<HubOptions> options)
1617

1718
public void Configure(HubOptions<THub> options)
1819
{
20+
// Do a deep copy, otherwise users modifying the HubOptions<THub> list would be changing the global options list
1921
options.SupportedProtocols = new List<string>(_hubOptions.SupportedProtocols.Count);
2022
foreach (var protocol in _hubOptions.SupportedProtocols)
2123
{
@@ -24,7 +26,12 @@ public void Configure(HubOptions<THub> options)
2426
options.KeepAliveInterval = _hubOptions.KeepAliveInterval;
2527
options.HandshakeTimeout = _hubOptions.HandshakeTimeout;
2628

27-
options.AdditionalHubProtocols = _hubOptions.AdditionalHubProtocols;
29+
// Do a deep copy, otherwise users modifying the HubOptions<THub> list would be changing the global options list
30+
options.AdditionalHubProtocols = new List<IHubProtocol>(_hubOptions.AdditionalHubProtocols.Count);
31+
foreach (var protocol in _hubOptions.AdditionalHubProtocols)
32+
{
33+
options.AdditionalHubProtocols.Add(protocol);
34+
}
2835
}
2936
}
3037
}

0 commit comments

Comments
 (0)