26
26
import software .amazon .awssdk .http .Protocol ;
27
27
import software .amazon .awssdk .http .nio .netty .internal .http2 .Http2MultiplexedChannelPool ;
28
28
import software .amazon .awssdk .http .nio .netty .internal .http2 .PingTracker ;
29
+ import software .amazon .awssdk .http .nio .netty .internal .utils .NettyUtils ;
29
30
30
31
/**
31
32
* Keys for attributes attached via {@link io.netty.channel.Channel#attr(AttributeKey)}.
@@ -36,70 +37,71 @@ public final class ChannelAttributeKey {
36
37
/**
37
38
* Future that when a protocol (http/1.1 or h2) has been selected.
38
39
*/
39
- public static final AttributeKey <CompletableFuture <Protocol >> PROTOCOL_FUTURE = AttributeKey . newInstance (
40
+ public static final AttributeKey <CompletableFuture <Protocol >> PROTOCOL_FUTURE = NettyUtils . getOrCreateAttributeKey (
40
41
"aws.http.nio.netty.async.protocolFuture" );
41
42
42
43
/**
43
44
* Reference to {@link Http2MultiplexedChannelPool} which stores information about leased streams for a multiplexed
44
45
* connection.
45
46
*/
46
- public static final AttributeKey <Http2MultiplexedChannelPool > HTTP2_MULTIPLEXED_CHANNEL_POOL = AttributeKey . newInstance (
47
- "aws.http.nio.netty.async.http2MultiplexedChannelPool" );
47
+ public static final AttributeKey <Http2MultiplexedChannelPool > HTTP2_MULTIPLEXED_CHANNEL_POOL =
48
+ NettyUtils . getOrCreateAttributeKey ( "aws.http.nio.netty.async.http2MultiplexedChannelPool" );
48
49
49
50
public static final AttributeKey <PingTracker > PING_TRACKER =
50
- AttributeKey . newInstance ("aws.http.nio.netty.async.h2.pingTracker" );
51
+ NettyUtils . getOrCreateAttributeKey ("aws.http.nio.netty.async.h2.pingTracker" );
51
52
52
53
public static final AttributeKey <Http2Connection > HTTP2_CONNECTION =
53
- AttributeKey . newInstance ("aws.http.nio.netty.async.http2Connection" );
54
+ NettyUtils . getOrCreateAttributeKey ("aws.http.nio.netty.async.http2Connection" );
54
55
55
56
public static final AttributeKey <Integer > HTTP2_INITIAL_WINDOW_SIZE =
56
- AttributeKey . newInstance ("aws.http.nio.netty.async.http2InitialWindowSize" );
57
+ NettyUtils . getOrCreateAttributeKey ("aws.http.nio.netty.async.http2InitialWindowSize" );
57
58
58
59
/**
59
60
* Value of the MAX_CONCURRENT_STREAMS from the server's SETTING frame.
60
61
*/
61
- public static final AttributeKey <Long > MAX_CONCURRENT_STREAMS = AttributeKey . newInstance (
62
+ public static final AttributeKey <Long > MAX_CONCURRENT_STREAMS = NettyUtils . getOrCreateAttributeKey (
62
63
"aws.http.nio.netty.async.maxConcurrentStreams" );
63
64
64
65
/**
65
66
* {@link AttributeKey} to keep track of whether we should close the connection after this request
66
67
* has completed.
67
68
*/
68
- static final AttributeKey <Boolean > KEEP_ALIVE = AttributeKey . newInstance ("aws.http.nio.netty.async.keepAlive" );
69
+ static final AttributeKey <Boolean > KEEP_ALIVE = NettyUtils . getOrCreateAttributeKey ("aws.http.nio.netty.async.keepAlive" );
69
70
70
71
/**
71
72
* Attribute key for {@link RequestContext}.
72
73
*/
73
- static final AttributeKey <RequestContext > REQUEST_CONTEXT_KEY = AttributeKey . newInstance (
74
+ static final AttributeKey <RequestContext > REQUEST_CONTEXT_KEY = NettyUtils . getOrCreateAttributeKey (
74
75
"aws.http.nio.netty.async.requestContext" );
75
76
76
- static final AttributeKey <Subscriber <? super ByteBuffer >> SUBSCRIBER_KEY = AttributeKey . newInstance (
77
+ static final AttributeKey <Subscriber <? super ByteBuffer >> SUBSCRIBER_KEY = NettyUtils . getOrCreateAttributeKey (
77
78
"aws.http.nio.netty.async.subscriber" );
78
79
79
- static final AttributeKey <Boolean > RESPONSE_COMPLETE_KEY = AttributeKey . newInstance (
80
+ static final AttributeKey <Boolean > RESPONSE_COMPLETE_KEY = NettyUtils . getOrCreateAttributeKey (
80
81
"aws.http.nio.netty.async.responseComplete" );
81
82
82
83
/**
83
84
* {@link AttributeKey} to keep track of whether we have received the {@link LastHttpContent}.
84
85
*/
85
- static final AttributeKey <Boolean > LAST_HTTP_CONTENT_RECEIVED_KEY = AttributeKey . newInstance (
86
+ static final AttributeKey <Boolean > LAST_HTTP_CONTENT_RECEIVED_KEY = NettyUtils . getOrCreateAttributeKey (
86
87
"aws.http.nio.netty.async.lastHttpContentReceived" );
87
88
88
- static final AttributeKey <CompletableFuture <Void >> EXECUTE_FUTURE_KEY = AttributeKey . newInstance (
89
+ static final AttributeKey <CompletableFuture <Void >> EXECUTE_FUTURE_KEY = NettyUtils . getOrCreateAttributeKey (
89
90
"aws.http.nio.netty.async.executeFuture" );
90
91
91
- static final AttributeKey <Long > EXECUTION_ID_KEY = AttributeKey . newInstance (
92
+ static final AttributeKey <Long > EXECUTION_ID_KEY = NettyUtils . getOrCreateAttributeKey (
92
93
"aws.http.nio.netty.async.executionId" );
93
94
94
95
/**
95
96
* Whether the channel is still in use
96
97
*/
97
- static final AttributeKey <Boolean > IN_USE = AttributeKey . newInstance ("aws.http.nio.netty.async.inUse" );
98
+ static final AttributeKey <Boolean > IN_USE = NettyUtils . getOrCreateAttributeKey ("aws.http.nio.netty.async.inUse" );
98
99
99
100
/**
100
101
* Whether the channel should be closed once it is released.
101
102
*/
102
- static final AttributeKey <Boolean > CLOSE_ON_RELEASE = AttributeKey .newInstance ("aws.http.nio.netty.async.closeOnRelease" );
103
+ static final AttributeKey <Boolean > CLOSE_ON_RELEASE = NettyUtils .getOrCreateAttributeKey (
104
+ "aws.http.nio.netty.async.closeOnRelease" );
103
105
104
106
private ChannelAttributeKey () {
105
107
}
0 commit comments