lokidundun commented on code in PR #7822:
URL: https://github.com/apache/incubator-seata/pull/7822#discussion_r2612778251
##########
core/src/main/java/org/apache/seata/core/rpc/netty/http/HttpDispatchHandler.java:
##########
@@ -149,16 +152,19 @@ private void sendResponse(ChannelHandlerContext ctx,
boolean keepAlive, Object r
response = new DefaultFullHttpResponse(
HttpVersion.HTTP_1_1, HttpResponseStatus.OK,
Unpooled.wrappedBuffer(Unpooled.EMPTY_BUFFER));
}
+ context.setResponse(response);
if (!keepAlive) {
ctx.writeAndFlush(response).addListeners(ChannelFutureListener.CLOSE);
} else {
ctx.writeAndFlush(response);
}
}
- private void sendErrorResponse(ChannelHandlerContext ctx,
HttpResponseStatus status, boolean keepAlive) {
+ private void sendErrorResponse(
+ ChannelHandlerContext ctx, HttpResponseStatus status, boolean
keepAlive, HttpFilterContext<?> context) {
FullHttpResponse response = new DefaultFullHttpResponse(
HttpVersion.HTTP_1_1, status,
Unpooled.wrappedBuffer(Unpooled.EMPTY_BUFFER));
+ context.setResponse(response);
Review Comment:
> What is the purpose of calling setResponse here?
Thanks for pointing this out. The original intention of putting the response
into HttpFilterContext is that error information is inherently part of the
response. Spring AOP aspects needs to access/judge the error status or error
code of the current request for additional processing. Maybe my understanding
might have some gaps—would love to hear your thoughts on this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]