You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/02/28 14:28:55 UTC

[GitHub] [incubator-inlong] luchunliang commented on a change in pull request #2782: [INLONG-2781][DataProxy] Update netty version to 4.x

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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org