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 2022/05/12 01:41:14 UTC

[james-project] branch master updated (8e8bf0bf28 -> 67682418b7)

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

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


    from 8e8bf0bf28 JAMES-3763 BlobStore backed MailRepository
     new 5f2271a1f7 JAMES-3737 IMAPServerTest: tests for non synchronized litterals
     new 05c1e70025 JAMES-3737 ImapRequestFrameDecoder: better manage framing
     new ca8417e942 JAMES-3737 IMAPServerTest: test cumulation upon framing
     new 181fadb433 JAMES-3737 ImapRequestFrameDecoder: remove buggy code
     new 67682418b7 [FIX] Filter non error logs as done previously

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../imapserver/netty/ImapRequestFrameDecoder.java  | 11 +--
 .../james/imapserver/netty/IMAPServerTest.java     | 91 ++++++++++++++++++++++
 testing/base/src/main/resources/logback-test.xml   |  3 +
 3 files changed, 96 insertions(+), 9 deletions(-)


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


[james-project] 01/05: JAMES-3737 IMAPServerTest: tests for non synchronized litterals

Posted by bt...@apache.org.
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 5f2271a1f74f1a27ad01fbe26de73e7e619cc3c7
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Wed May 11 10:43:29 2022 +0700

    JAMES-3737 IMAPServerTest: tests for non synchronized litterals
---
 .../james/imapserver/netty/IMAPServerTest.java     | 44 ++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java b/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java
index 0ac6057c5d..aea7bda099 100644
--- a/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java
+++ b/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java
@@ -338,6 +338,50 @@ class IMAPServerTest {
         }
     }
 
+    @Nested
+    class AppendNonSynchronizedLitterals {
+        IMAPServer imapServer;
+        private SocketChannel clientConnection;
+
+        @BeforeEach
+        void beforeEach() throws Exception {
+            imapServer = createImapServer("imapServerNoLimits.xml");
+            int port = imapServer.getListenAddresses().get(0).getPort();
+            memoryIntegrationResources.getMailboxManager()
+                .createMailbox(MailboxPath.inbox(USER), memoryIntegrationResources.getMailboxManager().createSystemSession(USER));
+            clientConnection = SocketChannel.open();
+            clientConnection.connect(new InetSocketAddress(LOCALHOST_IP, port));
+            readBytes(clientConnection);
+        }
+
+        @AfterEach
+        void tearDown() throws Exception {
+            clientConnection.close();
+            imapServer.destroy();
+        }
+
+        @Test
+        void appendShouldSucceedWhenNonSynchronized() throws Exception {
+            clientConnection.write(ByteBuffer.wrap(String.format("a0 LOGIN %s %s\r\n", USER.asString(), USER_PASS).getBytes(StandardCharsets.UTF_8)));
+            readBytes(clientConnection);
+
+            String msg = "Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)\r\n" +
+                "From: Fred Foobar <fo...@Blurdybloop.COM>\r\n" +
+                "Subject: afternoon meeting 2\r\n" +
+                "To: mooch@owatagu.siam.edu\r\n" +
+                "Message-Id: <B2...@Blurdybloop.COM>\r\n" +
+                "MIME-Version: 1.0\r\n" +
+                "Content-Type: TEXT/PLAIN; CHARSET=US-ASCII\r\n" +
+                "C:\r\n" +
+                "Hello Joe, could we change that to 4:00pm tomorrow?\r\n";
+            clientConnection.write(ByteBuffer.wrap(("A004 APPEND INBOX {" + msg.length() + "+}\r\n" +
+                msg + "\r\n").getBytes(StandardCharsets.UTF_8)));
+
+            assertThat(new String(readBytes(clientConnection), StandardCharsets.US_ASCII)).contains("APPEND completed.");
+
+        }
+    }
+
     @Nested
     class Compress {
         IMAPServer imapServer;


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


[james-project] 05/05: [FIX] Filter non error logs as done previously

Posted by bt...@apache.org.
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 67682418b7bfa668dfa45ddf51549b636bfe5525
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Wed May 11 14:15:43 2022 +0700

    [FIX] Filter non error logs as done previously
    
    Mistakenly commited change need to be reverted
---
 testing/base/src/main/resources/logback-test.xml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/testing/base/src/main/resources/logback-test.xml b/testing/base/src/main/resources/logback-test.xml
index 1fe8d21504..ddcf72c376 100644
--- a/testing/base/src/main/resources/logback-test.xml
+++ b/testing/base/src/main/resources/logback-test.xml
@@ -18,6 +18,9 @@
                         <pattern>%d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx</pattern>
                 </encoder>
                 <immediateFlush>false</immediateFlush>
+                <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+                        <level>ERROR</level>
+                </filter>
         </appender>
 
         <root level="WARN">


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


[james-project] 03/05: JAMES-3737 IMAPServerTest: test cumulation upon framing

Posted by bt...@apache.org.
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 ca8417e942fdd7c3f504fe6c729df91d8461e40d
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Wed May 11 14:12:12 2022 +0700

    JAMES-3737 IMAPServerTest: test cumulation upon framing
    
    Demonstrate that the buffer is not lost
---
 .../james/imapserver/netty/IMAPServerTest.java     | 31 ++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java b/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java
index ae12a8117c..33a8f60cba 100644
--- a/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java
+++ b/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java
@@ -372,7 +372,7 @@ class IMAPServerTest {
                 "Message-Id: <B2...@Blurdybloop.COM>\r\n" +
                 "MIME-Version: 1.0\r\n" +
                 "Content-Type: TEXT/PLAIN; CHARSET=US-ASCII\r\n" +
-                "C:\r\n" +
+                "\r\n" +
                 "Hello Joe, could we change that to 4:00pm tomorrow?\r\n";
             clientConnection.write(ByteBuffer.wrap(("A004 APPEND INBOX {" + msg.length() + "+}\r\n" +
                 msg + "\r\n").getBytes(StandardCharsets.UTF_8)));
@@ -393,13 +393,40 @@ class IMAPServerTest {
                 "Message-Id: <B2...@Blurdybloop.COM>\r\n" +
                 "MIME-Version: 1.0\r\n" +
                 "Content-Type: TEXT/PLAIN; CHARSET=US-ASCII\r\n" +
-                "C:\r\n" +
+                "\r\n" +
                 "Hello Joe, could we change that to 4:00pm tomorrow?\r\n";
             clientConnection.write(ByteBuffer.wrap(("A004 APPEND INBOX {" + msg.length() + "+}\r\n" +
                 msg + "\r\nA005 NOOP").getBytes(StandardCharsets.UTF_8)));
 
             assertThat(new String(readBytes(clientConnection), StandardCharsets.US_ASCII)).contains("APPEND completed.");
         }
+
+        @Test
+        void extraDataAfterFirstLineShouldNotBeLost() throws Exception {
+            clientConnection.write(ByteBuffer.wrap(String.format("a0 LOGIN %s %s\r\n", USER.asString(), USER_PASS).getBytes(StandardCharsets.UTF_8)));
+            readBytes(clientConnection);
+
+            String msg = " Mon, 7 Feb 1994 21:52:25 -0800 (PST)\r\n" +
+                "From: Fred Foobar <fo...@Blurdybloop.COM>\r\n" +
+                "Subject: afternoon meeting 2\r\n" +
+                "To: mooch@owatagu.siam.edu\r\n" +
+                "Message-Id: <B2...@Blurdybloop.COM>\r\n" +
+                "MIME-Version: 1.0\r\n" +
+                "Content-Type: TEXT/PLAIN; CHARSET=US-ASCII\r\n" +
+                "\r\n" +
+                "Hello Joe, could we change that to 4:00pm tomorrow?\r\n";
+            clientConnection.write(ByteBuffer.wrap(("A004 APPEND INBOX {" + (msg.length() + 4) + "+}\r\nDATE").getBytes(StandardCharsets.UTF_8)));
+
+            Thread.sleep(100); // Forces separate TCP messages
+
+            clientConnection.write(ByteBuffer.wrap((msg).getBytes(StandardCharsets.UTF_8)));
+
+            Thread.sleep(100); // Forces separate TCP messages
+
+            clientConnection.write(ByteBuffer.wrap(("\r\n").getBytes(StandardCharsets.UTF_8)));
+
+            assertThat(new String(readBytes(clientConnection), StandardCharsets.US_ASCII)).contains("APPEND completed.");
+        }
     }
 
     @Nested


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


[james-project] 02/05: JAMES-3737 ImapRequestFrameDecoder: better manage framing

Posted by bt...@apache.org.
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 05c1e70025a7198fbe70b75a062500657bc80295
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Wed May 11 12:52:52 2022 +0700

    JAMES-3737 ImapRequestFrameDecoder: better manage framing
---
 .../imapserver/netty/ImapRequestFrameDecoder.java    |  6 ++----
 .../james/imapserver/netty/IMAPServerTest.java       | 20 ++++++++++++++++++++
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapRequestFrameDecoder.java b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapRequestFrameDecoder.java
index 9cd437eaf9..43ad58a086 100644
--- a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapRequestFrameDecoder.java
+++ b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapRequestFrameDecoder.java
@@ -267,15 +267,13 @@ public class ImapRequestFrameDecoder extends ByteToMessageDecoder implements Net
     }
 
     public void disableFraming(ChannelHandlerContext ctx) {
-        if (framingEnabled.get()) {
+        if (framingEnabled.getAndSet(false)) {
             ctx.channel().pipeline().remove(FRAMER);
-            framingEnabled.set(false);
         }
     }
 
     public void enableFraming(ChannelHandlerContext ctx) {
-        if (!framingEnabled.get()) {
-            framingEnabled.set(true);
+        if (!framingEnabled.getAndSet(true)) {
             ctx.channel().pipeline().addBefore(REQUEST_DECODER, FRAMER,
                 new SwitchableLineBasedFrameDecoder(ctx.channel().pipeline(), maxFrameLength, false));
         }
diff --git a/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java b/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java
index aea7bda099..ae12a8117c 100644
--- a/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java
+++ b/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java
@@ -380,6 +380,26 @@ class IMAPServerTest {
             assertThat(new String(readBytes(clientConnection), StandardCharsets.US_ASCII)).contains("APPEND completed.");
 
         }
+
+        @Test
+        void partialCommandAfterNonSynchronizedLiteralShouldNotFail() throws Exception {
+            clientConnection.write(ByteBuffer.wrap(String.format("a0 LOGIN %s %s\r\n", USER.asString(), USER_PASS).getBytes(StandardCharsets.UTF_8)));
+            readBytes(clientConnection);
+
+            String msg = "Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)\r\n" +
+                "From: Fred Foobar <fo...@Blurdybloop.COM>\r\n" +
+                "Subject: afternoon meeting 2\r\n" +
+                "To: mooch@owatagu.siam.edu\r\n" +
+                "Message-Id: <B2...@Blurdybloop.COM>\r\n" +
+                "MIME-Version: 1.0\r\n" +
+                "Content-Type: TEXT/PLAIN; CHARSET=US-ASCII\r\n" +
+                "C:\r\n" +
+                "Hello Joe, could we change that to 4:00pm tomorrow?\r\n";
+            clientConnection.write(ByteBuffer.wrap(("A004 APPEND INBOX {" + msg.length() + "+}\r\n" +
+                msg + "\r\nA005 NOOP").getBytes(StandardCharsets.UTF_8)));
+
+            assertThat(new String(readBytes(clientConnection), StandardCharsets.US_ASCII)).contains("APPEND completed.");
+        }
     }
 
     @Nested


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


[james-project] 04/05: JAMES-3737 ImapRequestFrameDecoder: remove buggy code

Posted by bt...@apache.org.
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 181fadb4337496e79b1d230ef302568a6f82955c
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Wed May 11 14:13:40 2022 +0700

    JAMES-3737 ImapRequestFrameDecoder: remove buggy code
    
    Unneeded, the cumulation cary over when disabling framing do not need it.
    
    Buggy: next handler do not expect a ByteBuf
    
    java.lang.ClassCastException: class io.netty.buffer.PooledDuplicatedByteBuf cannot be cast to class org.apache.james.imap.api.ImapMessage (io.netty.buffer.PooledDuplicatedByteBuf and org.apache.james.imap.api.ImapMessage are in unnamed module of loader 'app')
---
 .../org/apache/james/imapserver/netty/ImapRequestFrameDecoder.java   | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapRequestFrameDecoder.java b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapRequestFrameDecoder.java
index 43ad58a086..88e3b9fb78 100644
--- a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapRequestFrameDecoder.java
+++ b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapRequestFrameDecoder.java
@@ -153,11 +153,6 @@ public class ImapRequestFrameDecoder extends ByteToMessageDecoder implements Net
 
         // SwitchableDelimiterBasedFrameDecoder added further to JAMES-1436.
         disableFraming(ctx);
-        if (in.readableBytes() > 0) {
-            ByteBuf spareBytes = in.retainedDuplicate();
-            internalBuffer().clear();
-            ctx.fireChannelRead(spareBytes);
-        }
         in.readerIndex(readerIndex);
     }
 


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