This is an automated email from the ASF dual-hosted git repository.

rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
     new b8ddca505c [ENHANCEMENT] Decrease log level for "NotSslRecordException"
b8ddca505c is described below

commit b8ddca505cc833fef8417f8acfa1aea9b862a0ef
Author: Benoit TELLIER <[email protected]>
AuthorDate: Sun Mar 10 23:26:06 2024 +0100

    [ENHANCEMENT] Decrease log level for "NotSslRecordException"
---
 .../apache/james/protocols/netty/BasicChannelInboundHandler.java  | 8 ++++++++
 .../apache/james/imapserver/netty/ImapChannelUpstreamHandler.java | 8 ++++++++
 2 files changed, 16 insertions(+)

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 d79138328f..7871cb3fbd 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
@@ -57,6 +57,7 @@ import io.netty.handler.codec.DecoderException;
 import io.netty.handler.codec.TooLongFrameException;
 import io.netty.handler.codec.haproxy.HAProxyMessage;
 import io.netty.handler.codec.haproxy.HAProxyProxiedProtocol;
+import io.netty.handler.ssl.NotSslRecordException;
 import io.netty.util.AttributeKey;
 
 /**
@@ -275,6 +276,8 @@ public class BasicChannelInboundHandler extends 
ChannelInboundHandlerAdapter imp
                     LOGGER.info("Socket exception encountered: {}", 
cause.getMessage());
                 } else if (isSslHandshkeException(cause)) {
                     LOGGER.info("SSH handshake rejected {}", 
cause.getMessage());
+                } else if (isNotSslRecordException(cause)) {
+                    LOGGER.info("Not an SSL record {}", cause.getMessage());
                 } else if (!(cause instanceof ClosedChannelException)) {
                     LOGGER.error("Unable to process request", cause);
                 }
@@ -288,6 +291,11 @@ public class BasicChannelInboundHandler extends 
ChannelInboundHandlerAdapter imp
             cause.getCause() instanceof SSLHandshakeException;
     }
 
+    private boolean isNotSslRecordException(Throwable cause) {
+        return cause instanceof DecoderException &&
+            cause.getCause() instanceof NotSslRecordException;
+    }
+
     @Override
     public void pushLineHandler(ChannelInboundHandlerAdapter 
lineHandlerUpstreamHandler) {
         behaviourOverrides.addFirst(lineHandlerUpstreamHandler);
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 5c464c9edd..934a5d4483 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
@@ -63,6 +63,7 @@ import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelInboundHandlerAdapter;
 import io.netty.handler.codec.DecoderException;
 import io.netty.handler.codec.TooLongFrameException;
+import io.netty.handler.ssl.NotSslRecordException;
 import io.netty.util.Attribute;
 import reactor.core.Disposable;
 import reactor.core.publisher.Flux;
@@ -284,6 +285,8 @@ public class ImapChannelUpstreamHandler extends 
ChannelInboundHandlerAdapter imp
                 LOGGER.info("Socket exception encountered: {}", 
cause.getMessage());
             } else if (isSslHandshkeException(cause)) {
                 LOGGER.info("SSH handshake rejected {}", cause.getMessage());
+            } else if (isNotSslRecordException(cause)) {
+                LOGGER.info("Not an SSL record {}", cause.getMessage());
             } else if (!(cause instanceof ClosedChannelException)) {
                 LOGGER.warn("Error while processing imap request", cause);
             }
@@ -322,6 +325,11 @@ public class ImapChannelUpstreamHandler extends 
ChannelInboundHandlerAdapter imp
             && cause.getCause() instanceof SSLHandshakeException;
     }
 
+    private boolean isNotSslRecordException(Throwable cause) {
+        return cause instanceof DecoderException &&
+            cause.getCause() instanceof NotSslRecordException;
+    }
+
     private void manageRejectedException(ChannelHandlerContext ctx, 
ReactiveThrottler.RejectedException cause) throws IOException {
         if (cause.getImapMessage() instanceof AbstractImapRequest) {
             AbstractImapRequest req = (AbstractImapRequest) 
cause.getImapMessage();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to