You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2024/02/08 08:42:40 UTC
(james-project) 01/03: JAMES-3981 Lower log level of closed connections
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit b14a35d162f57bacda4938d44ab2384a161fdfc8
Author: Benoit TELLIER <bt...@linagora.com>
AuthorDate: Tue Feb 6 16:43:00 2024 +0100
JAMES-3981 Lower log level of closed connections
- Benign user events
- That might even be triggered on logout
- Load balancers might rely on TCP checks triggering such logs
upon their health checks, eg HAProxy
---
.../james/protocols/netty/BasicChannelInboundHandler.java | 3 +++
.../james/imapserver/netty/ImapChannelUpstreamHandler.java | 10 +++++++++-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/protocols/netty/src/main/java/org/apache/james/protocols/netty/BasicChannelInboundHandler.java b/protocols/netty/src/main/java/org/apache/james/protocols/netty/BasicChannelInboundHandler.java
index 1e4470fd48..92762d8157 100644
--- a/protocols/netty/src/main/java/org/apache/james/protocols/netty/BasicChannelInboundHandler.java
+++ b/protocols/netty/src/main/java/org/apache/james/protocols/netty/BasicChannelInboundHandler.java
@@ -23,6 +23,7 @@ import static org.apache.james.protocols.api.ProtocolSession.State.Connection;
import java.io.Closeable;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
+import java.net.SocketException;
import java.nio.channels.ClosedChannelException;
import java.util.Deque;
import java.util.LinkedList;
@@ -269,6 +270,8 @@ public class BasicChannelInboundHandler extends ChannelInboundHandlerAdapter imp
}
if (cause instanceof ClosedChannelException) {
LOGGER.info("Channel closed before we could send in flight messages to the users (ClosedChannelException): {}", cause.getMessage());
+ } else if (cause instanceof SocketException) {
+ LOGGER.info("Socket exception encountered: {}", cause.getMessage());
} else {
LOGGER.error("Unable to process request", cause);
}
diff --git a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapChannelUpstreamHandler.java b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapChannelUpstreamHandler.java
index 40a3aab57e..fb76cde4fb 100644
--- a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapChannelUpstreamHandler.java
+++ b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapChannelUpstreamHandler.java
@@ -23,6 +23,8 @@ import static org.apache.james.imapserver.netty.IMAPServer.AuthenticationConfigu
import java.io.Closeable;
import java.io.IOException;
import java.net.InetSocketAddress;
+import java.net.SocketException;
+import java.nio.channels.ClosedChannelException;
import java.time.Duration;
import java.util.NoSuchElementException;
import java.util.Optional;
@@ -270,7 +272,13 @@ public class ImapChannelUpstreamHandler extends ChannelInboundHandlerAdapter imp
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
try (Closeable closeable = mdc(ctx).build()) {
- LOGGER.warn("Error while processing imap request", cause);
+ if (cause instanceof ClosedChannelException) {
+ LOGGER.info("Channel was closed");
+ } else if (cause instanceof SocketException) {
+ LOGGER.info("Socket exception encountered: {}", cause.getMessage());
+ } else {
+ LOGGER.warn("Error while processing imap request", cause);
+ }
if (cause instanceof TooLongFrameException) {
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org