22
33import io .netty .channel .Channel ;
44import io .netty .channel .ChannelHandlerContext ;
5+ import io .netty .handler .codec .http .FullHttpResponse ;
56import io .netty .handler .codec .http .HttpRequest ;
67
78import java .util .concurrent .ConcurrentHashMap ;
@@ -30,7 +31,7 @@ public static HttpRequestContext getInstance() {
3031 }
3132
3233 public void setRequestChannel (HttpRequest httpRequest , Channel channel ) {
33- requestChannel .putIfAbsent (httpRequest , channel );
34+ requestChannel .put (httpRequest , channel );
3435 set (channel , RequestConstant .HTTPREQUEST , httpRequest );
3536 }
3637
@@ -47,9 +48,9 @@ public void set(Channel channel, String key, Object value) {
4748 ConcurrentHashMap <String , Object > context = getContext (channel );
4849 if (context == null ) {
4950 context = new ConcurrentHashMap <>();
50- channelContext .putIfAbsent (channel , context );
51+ channelContext .put (channel , context );
5152 }
52- context .putIfAbsent (key , value );
53+ context .put (key , value );
5354 }
5455
5556 public <T > T get (HttpRequest httpRequest , String key ) {
@@ -102,15 +103,15 @@ public void setException(Channel channel, Exception exception) {
102103 set (channel , RequestConstant .EXCEPTION , exception );
103104 }
104105
105- public void setResponse (Channel channel , Object response ) {
106+ public void setResponse (Channel channel , FullHttpResponse response ) {
106107 set (channel , RequestConstant .RESPONSE , response );
107108 }
108109
109- public Object getResponse (Channel channel ) {
110+ public FullHttpResponse getResponse (Channel channel ) {
110111 return get (channel , RequestConstant .RESPONSE );
111112 }
112113
113- public Object getResponse (HttpRequest httpRequest ) {
114+ public FullHttpResponse getResponse (HttpRequest httpRequest ) {
114115 return get (httpRequest , RequestConstant .RESPONSE );
115116 }
116117}
0 commit comments