Skip to content

Commit 77314aa

Browse files
committed
清除Context数据
1 parent ed84995 commit 77314aa

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/main/java/love/wangqi/context/ContextUtil.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,11 @@ public static void setException(Channel channel, Exception exception) {
4242
public static Exception getException(Channel channel) {
4343
return channel.attr(Attributes.EXCEPTION).get();
4444
}
45+
46+
public static void clear(Channel channel) {
47+
channel.attr(Attributes.REQUEST).set(null);
48+
channel.attr(Attributes.RESPONSE).set(null);
49+
channel.attr(Attributes.KEEPALIVE).set(null);
50+
channel.attr(Attributes.EXCEPTION).set(null);
51+
}
4552
}

src/main/java/love/wangqi/core/DefaultChannelWriteFinishListener.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public void operationComplete(ChannelFuture future) throws Exception {
2323
logger.debug("======= serverChannelId: {}", channel.id());
2424

2525
ContextUtil.getRequest(channel).release();
26+
ContextUtil.clear(channel);
2627

2728
if (!keepAlive) {
2829
channel.close();

0 commit comments

Comments
 (0)