Make log shorter on IOException. This is not an ordinary exception. Info level. Others will be fired under error log level

This commit is contained in:
Sergey Matvienko 2022-07-18 11:33:55 +03:00
parent ed6324e7eb
commit d0237c4536

View File

@ -883,7 +883,16 @@ public class MqttTransportHandler extends ChannelInboundHandlerAdapter implement
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
if (cause instanceof IOException) {
if (log.isInfoEnabled()) {
log.info("[{}][{}] IOException: {}", sessionId,
Optional.ofNullable(this.deviceSessionCtx.getDeviceInfo()).map(TransportDeviceInfo::getDeviceName).orElse(""),
cause.getMessage());
}
} else {
log.error("[{}] Unexpected Exception", sessionId, cause);
}
ctx.close();
if (cause instanceof OutOfMemoryError) {
log.error("Received critical error. Going to shutdown the service.");