luchunliang commented on a change in pull request #2782:
URL: https://github.com/apache/incubator-inlong/pull/2782#discussion_r815932636
##########
File path:
inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/source/tcp/InlongTcpChannelHandler.java
##########
@@ -223,41 +208,59 @@ private void responsePackage(ResultCode code,
MessageEvent e)
* exceptionCaught
*
* @param ctx
- * @param e
+ * @param cause
* @throws Exception
*/
@Override
- public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
throws Exception {
- LOG.error("exception caught", e.getCause());
- super.exceptionCaught(ctx, e);
- if (e.getChannel() != null) {
+ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
+ LOG.error("exception caught cause = {}", cause);
+ if (ctx.channel() != null) {
try {
- e.getChannel().disconnect();
- e.getChannel().close();
+ ctx.fireExceptionCaught(cause);
Review comment:
If ctx.fireExceptionCaught get an Exception, the operation of disconnect
and close will not be invoked.
##########
File path:
inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/source/tcp/InlongTcpChannelHandler.java
##########
@@ -191,28 +175,29 @@ private void addMetric(boolean result, long size, Event
event) {
/**
* responsePackage
- *
+ *
+ * @param ctx
* @param code
- * @param e
* @throws Exception
*/
- private void responsePackage(ResultCode code, MessageEvent e)
+ private void responsePackage(ChannelHandlerContext ctx, ResultCode code)
throws Exception {
ResponseInfo.Builder builder = ResponseInfo.newBuilder();
builder.setResult(code);
// encode
byte[] responseBytes = builder.build().toByteArray();
//
- ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(responseBytes);
-
- Channel remoteChannel = e.getChannel();
+ ByteBuf buffer = ByteBufAllocator.DEFAULT.buffer(responseBytes.length);
+ buffer.writeBytes(responseBytes);
Review comment:
It is better to use Unpooled.wrappedBuffer(byte[]).
--
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]