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 2f8dff49da JAMES-4101 Wrap SMTp startTLS into a NETTY transaction
2f8dff49da is described below

commit 2f8dff49daea09674fdd40f01c25ad445b593499
Author: Benoit TELLIER <btell...@linagora.com>
AuthorDate: Mon Jan 13 22:14:33 2025 +0100

    JAMES-4101 Wrap SMTp startTLS into a NETTY transaction
    
    Turn off auto-read and run it on the event loop like we do in IMAP
---
 .../james/protocols/netty/NettyProtocolTransport.java       | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git 
a/protocols/netty/src/main/java/org/apache/james/protocols/netty/NettyProtocolTransport.java
 
b/protocols/netty/src/main/java/org/apache/james/protocols/netty/NettyProtocolTransport.java
index 8c1b447ba6..60b3191e92 100644
--- 
a/protocols/netty/src/main/java/org/apache/james/protocols/netty/NettyProtocolTransport.java
+++ 
b/protocols/netty/src/main/java/org/apache/james/protocols/netty/NettyProtocolTransport.java
@@ -104,10 +104,15 @@ public class NettyProtocolTransport extends 
AbstractProtocolTransport {
 
     @Override
     protected void writeToClient(byte[] bytes, ProtocolSession session, 
boolean startTLS) {
-        channel.writeAndFlush(Unpooled.wrappedBuffer(bytes));
-
-        if (startTLS) {
-            prepareStartTLS();
+        if (!startTLS) {
+            channel.writeAndFlush(Unpooled.wrappedBuffer(bytes));
+        } else {
+            channel.eventLoop().execute(() -> {
+                channel.config().setAutoRead(false);
+                channel.writeAndFlush(Unpooled.wrappedBuffer(bytes));
+                prepareStartTLS();
+                channel.config().setAutoRead(true);
+            });
         }
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org
For additional commands, e-mail: notifications-h...@james.apache.org

Reply via email to