File tree 1 file changed +13
-6
lines changed
src/DotNetty.Common/Utilities
1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,18 @@ namespace DotNetty.Common.Utilities
5
5
{
6
6
using System ;
7
7
8
+ internal static class AttributeKey
9
+ {
10
+ // Keep the instance of AttributeConstantPool out of generic classes, to make it an really singleton for different generic types.
11
+ // see https://github.com/Azure/DotNetty/issues/498
12
+ public static readonly ConstantPool Pool = new AttributeConstantPool ( ) ;
13
+
14
+ sealed class AttributeConstantPool : ConstantPool
15
+ {
16
+ protected override IConstant NewConstant < TValue > ( int id , string name ) => new AttributeKey < TValue > ( id , name ) ;
17
+ } ;
18
+ }
19
+
8
20
/// <summary>
9
21
/// Key which can be used to access <seealso cref="Attribute" /> out of the <see cref="IAttributeMap" />. Be aware that
10
22
/// it is not be possible to have multiple keys with the same name.
@@ -14,12 +26,7 @@ namespace DotNetty.Common.Utilities
14
26
/// </typeparam>
15
27
public sealed class AttributeKey < T > : AbstractConstant < AttributeKey < T > >
16
28
{
17
- public static readonly ConstantPool Pool = new AttributeConstantPool ( ) ;
18
-
19
- sealed class AttributeConstantPool : ConstantPool
20
- {
21
- protected override IConstant NewConstant < TValue > ( int id , string name ) => new AttributeKey < TValue > ( id , name ) ;
22
- } ;
29
+ public static readonly ConstantPool Pool = AttributeKey . Pool ;
23
30
24
31
/// <summary>Returns the singleton instance of the {@link AttributeKey} which has the specified <c>name</c>.</summary>
25
32
public static AttributeKey < T > ValueOf ( string name ) => ( AttributeKey < T > ) Pool . ValueOf < T > ( name ) ;
You can’t perform that action at this time.
0 commit comments