funky-eyes commented on code in PR #7451:
URL: https://github.com/apache/incubator-seata/pull/7451#discussion_r2157256565
##########
core/src/main/java/org/apache/seata/core/protocol/detector/HttpDetector.java:
##########
@@ -52,10 +67,59 @@ private boolean startsWith(ByteBuf buffer, String prefix) {
@Override
public ChannelHandler[] getHandlers() {
+ HttpServerCodec sourceCodec = new HttpServerCodec();
+ HttpServerUpgradeHandler upgradeHandler =
getHttpServerUpgradeHandler(sourceCodec);
+
+ ChannelInboundHandlerAdapter upgradeCleanupHandler = new
ChannelInboundHandlerAdapter() {
+ @Override
+ public void userEventTriggered(ChannelHandlerContext ctx, Object
evt) throws Exception {
+ if (evt instanceof HttpServerUpgradeHandler.UpgradeEvent) {
+ ChannelPipeline p = ctx.pipeline();
+ p.remove(HttpObjectAggregator.class);
+ p.remove(HttpDispatchHandler.class);
+ }
+ super.userEventTriggered(ctx, evt);
+ }
+ };
+
+ ChannelInboundHandlerAdapter finalExceptionHandler = new
ChannelInboundHandlerAdapter() {
+ @Override
+ public void exceptionCaught(ChannelHandlerContext ctx, Throwable
cause) {
+ if (cause instanceof java.io.IOException) {
+ LOGGER.trace("Connection closed by client: {}",
cause.getMessage());
+ } else {
+ LOGGER.error("Exception caught in HTTP pipeline: ", cause);
+ }
+ ctx.close();
+ }
+ };
Review Comment:
> Is it okay not to override methods like `channelInactive` and
`channelUnregistered`?
Since most HTTP connections are short-lived, if you do not override the
exceptionCaught method, a large number of unexpected connection closed
exceptions will be output. For example, if you use the curl command to simulate
a request, you will encounter such exceptions.
--
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]