You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by "roger zhang (JIRA)" <se...@james.apache.org> on 2013/03/19 04:53:17 UTC

[jira] [Commented] (JAMES-1436) APPEND IMAP command can result in JAMES IMAP waiting indefinitely for data

    [ https://issues.apache.org/jira/browse/JAMES-1436?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13606021#comment-13606021 ] 

roger zhang commented on JAMES-1436:
------------------------------------

when i used SwitchableDelimiterBasedFrameDecoder to replace old method, if imap search command return issue. the imap process will be block .
import javax.mail.Session;
import javax.mail.Store;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.search.*;
import java.util.Properties;

public class ImapSearchMail {

    public static void main(String args[]) throws Exception {
        String host = "127.0.0.1";
        String username = "1@roger.com";
        String password = "1"; // passwd
        Properties props = new Properties();
        props.put("mail.debug", "true");
        Session session = Session.getDefaultInstance(props, null);
        Store store = session.getStore("imap");
        store.connect(host, username, password);
        Folder folder = store.getFolder("INBOX");
        folder.open(Folder.READ_ONLY);

        SearchTerm subjectTerm = new SubjectTerm("java培训");
        SearchTerm fromTerm = new FromStringTerm("采购");
        SearchTerm recipientTerm = new RecipientStringTerm(Message.RecipientType.TO,"张三");
        SearchTerm ccRecipientTerm = new RecipientStringTerm(Message.RecipientType.CC,"李四");
        SearchTerm bccRecipientTerm = new RecipientStringTerm(Message.RecipientType.BCC,"王五");
        SearchTerm bodyTerm = new BodyTerm("天天向上");
 

        SearchTerm[] searchTerms = new SearchTerm[6];
        searchTerms[0] = subjectTerm;
        searchTerms[1] = bodyTerm;
        searchTerms[2] = fromTerm;
        searchTerms[3] = recipientTerm;
        searchTerms[4] = ccRecipientTerm;
        searchTerms[5] = bccRecipientTerm;


        //SearchTerm orTerm = new OrTerm(searchTerms);
        SearchTerm andTerm = new AndTerm(searchTerms);
        Message[] msgs = folder.search(andTerm);
        System.out.println(msgs.length);
        folder.close(false);
        store.close();
    }
}
                
> APPEND IMAP command can result in JAMES IMAP waiting indefinitely for data
> --------------------------------------------------------------------------
>
>                 Key: JAMES-1436
>                 URL: https://issues.apache.org/jira/browse/JAMES-1436
>             Project: James Server
>          Issue Type: Bug
>          Components: IMAPServer
>    Affects Versions: Trunk, 3.0-beta4, 3.0.0-beta5
>         Environment: Ubuntu 12.04 x86_64
>            Reporter: Samant Maharaj
>         Attachments: JAMES-1436.patch, JAMES-1436.patch.r1432540, ThunderbirdAndIMAPserver.log
>
>
> When processing an IMAP APPEND command, the Netty stack in JAMES IMAP can get into a state where the ImapRequestFrameDecoder will wait for a number message bytes that will never arrive.
> This has the effect of causing the IMAP client to also block indefinitely waiting for a response from the server.
> Root Cause:
> This is due to a race condition when the DelimiterBasedFrameDecoder is removed from the Netty pipeline by the ImapRequestFrameDecoder.
> If the DelimiterBasedFrameDecoder still contains less than one line of data in its buffer, that data will never be flushed and forwarded down the pipeline. The effect of this is that a small number of bytes, typically from the early part of the message are omitted and the final byte count does not match the value calculated from the APPEND command. This results in the APPEND command never being completely decoded and hence no append actually takes place nor does a response get sent to the client.
> In order to reliably trigger this bug, JAMES was configured to accept a remote debugging connection and a conditional breakpoint set at org.jboss.netty.handler.codec.frame.FrameDecoder:439. The condition was set to 'Thread.sleep(200l); false'. This results in introducing a 200ms delay on each frame decoding loop without actually hitting the breakpoint. The effect of this is to allow the threadpool running ImapRequestFrameDecoder time to consume the individual frames and remove the DelimiterBasedFrameDecoder from the pipeline.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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