rdhabalia commented on a change in pull request #1107: Log only first exception 
in the connection exception handler
URL: https://github.com/apache/incubator-pulsar/pull/1107#discussion_r163666414
 
 

 ##########
 File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ClientCnx.java
 ##########
 @@ -152,7 +153,24 @@ public void channelInactive(ChannelHandlerContext ctx) 
throws Exception {
 
     @Override
     public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) 
throws Exception {
-        log.warn("{} Exception caught: {}", ctx.channel(), cause.getMessage(), 
cause);
+        if (state != State.Failed) {
+            if (cause instanceof NativeIoException) {
+                // No need to report stack trace for known exceptions that 
happen in disconnections
+                log.warn("[{}] Got exception {} : {}", remoteAddress, 
cause.getClass().getSimpleName(),
+                        cause.getMessage());
+            } else {
+                log.warn("[{}] Got exception: {}", remoteAddress, 
cause.getMessage(), cause);
 
 Review comment:
   Instead duplicate logging logic, should we do:
   ```
   log.warn("[{}] Got exception: {}", remoteAddress, cause.getMessage(), (cause 
instanceof NativeIoException) ? cause ? null);
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to