lrhkobe opened a new issue #476:
URL: https://github.com/apache/incubator-eventmesh/issues/476
## Bug Report
### Describe the bug
When exception occured in the method of `channelRead0`, it will be thrown,
and handled by the method 'exceptionCaught' in the class of
`EventMeshTcpExceptionHandler` .
```
public class EventMeshTcpMessageDispatcher extends
SimpleChannelInboundHandler<Package> {
@Override
protected void channelRead0(ChannelHandlerContext ctx, Package pkg)
throws Exception {
try {
...
dispatch(ctx, pkg, startTime, cmd);
} catch (Exception e) {
logger.error("exception occurred while
pkg|cmd={}|pkg={}|errMsg={}", cmd, pkg, e);
//throw new RuntimeException(e);
throw e;
}
}
}
```
When EventMesh caught the exception, it will send goodbye instruction to the
client, that means the biz exception caused the connection close of client. It
seems unreasonable.
```
public class EventMeshTcpExceptionHandler extends ChannelDuplexHandler {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
throws Exception {
Session session =
eventMeshTCPServer.getClientSessionGroupMapping().getSession(ctx);
UserAgent client = session == null ? null : session.getClient();
logger.error("exceptionCaught, push goodbye to
client|user={},errMsg={}", client, cause.fillInStackTrace());
String errMsg;
if (cause.toString().contains("value not one of declared Enum
instance names")) {
errMsg = "Unknown Command type";
} else {
errMsg = cause.toString();
}
if (session != null) {
EventMeshTcp2Client.goodBye2Client(eventMeshTCPServer, session,
errMsg, OPStatus.FAIL.getCode(),
eventMeshTCPServer.getClientSessionGroupMapping());
} else {
EventMeshTcp2Client.goodBye2Client(ctx, errMsg,
eventMeshTCPServer.getClientSessionGroupMapping(),
eventMeshTCPServer.getEventMeshTcpMonitor());
}
}
}
```
--
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]