未验证 提交 046e9ab8 编写于 作者: L Liang Zhang 提交者: GitHub

Log error message for unexpected exception only (#7414)

* Log error message if not runtime exception only

* Add todo
上级 ffee7832
......@@ -74,10 +74,12 @@ public final class CommandExecutorTask implements Runnable {
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
log.error("Exception occur: ", ex);
context.writeAndFlush(databaseProtocolFrontendEngine.getCommandExecuteEngine().getErrorPacket(ex));
Optional<DatabasePacket<?>> databasePacket = databaseProtocolFrontendEngine.getCommandExecuteEngine().getOtherPacket();
databasePacket.ifPresent(context::writeAndFlush);
if (!isExpectedException(ex)) {
log.error("Exception occur: ", ex);
}
} finally {
if (isNeedFlush) {
context.flush();
......@@ -86,6 +88,11 @@ public final class CommandExecutorTask implements Runnable {
}
}
// TODO finish expected exception
private boolean isExpectedException(final Exception ex) {
return ex instanceof RuntimeException;
}
private boolean executeCommand(final ChannelHandlerContext context, final PacketPayload payload, final BackendConnection backendConnection) throws SQLException {
CommandExecuteEngine commandExecuteEngine = databaseProtocolFrontendEngine.getCommandExecuteEngine();
CommandPacketType type = commandExecuteEngine.getCommandPacketType(payload);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册