Uploaded image for project: 'James Server'
  1. James Server
  2. JAMES-2278

IMAP QRESYNC (RFC-5162) is buggy

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.0, master, 3.0.1
    • 3.7.0
    • IMAPServer

    Description

      As reported by lmilev on the gitter chat, passing known sequence sets to QRESYNC leads to an error in the IMAP layer:

      INFO | jvm 1 | 2018/01/03 12:25:15 | [imapserver-executor-17] ERROR org.apache.james.imap.processor.base.AbstractChainedProcessor - Error while processing IMAP request
      INFO | jvm 1 | 2018/01/03 12:25:15 | java.lang.IndexOutOfBoundsException: Index: 2, Size: 2
      INFO | jvm 1 | 2018/01/03 12:25:15 | at java.util.ArrayList.rangeCheck(ArrayList.java:653)
      INFO | jvm 1 | 2018/01/03 12:25:15 | at java.util.ArrayList.get(ArrayList.java:429)
      INFO | jvm 1 | 2018/01/03 12:25:15 | at org.apache.james.imap.processor.AbstractSelectionProcessor.respond(AbstractSelectionProcessor.java:240)
      INFO | jvm 1 | 2018/01/03 12:25:15 | at org.apache.james.imapserver.netty.ImapChannelUpstreamHandler.messageReceived(ImapChannelUpstreamHandler.java:194)
      

      I tried to write a MPT test but it is not trivial as it depends on random values (UIDVALIDITY) and non fixed values (MODSEQ). Moreover the code is messy, dirty and not explicit.

      The incriminated lines seems to be:

      if (knownUidsList.size() > index++) {
           int msnAsInt = msn.intValue();
           MessageUid knownUid = knownUidsList.get(index);
           // Complicated sequential stuff
      }
      

      As this little test shows it:

          @Test
          public void test() {
              int i = 0;
              System.out.println(i++);
              System.out.println(i++);
          }
      
      // Will output
      // 0
      // 1
      

      The index can clearly be out of range.

      if (knownUidsList.size() > ++index) {
           int msnAsInt = msn.intValue();
           MessageUid knownUid = knownUidsList.get(index);
           // Complicated sequential stuff
      }
      

      Should fix the issue.

      We should find a way to provide at least unit tests for that issue.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            btellier Benoit Tellier
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 0.5h
                0.5h

                Slack

                  Issue deployment