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

JMS mail queue caught in infinite loop.

    XMLWordPrintableJSON

    Details

    • Type: Wish
    • Status: Closed
    • Priority: Major
    • Resolution: Not A Problem
    • Affects Version/s: 3.0.0, master
    • Fix Version/s: None
    • Component/s: Queue
    • Labels:
      None
    • Flags:
      Important

      Description

      Background

      When JMSMail queue is empty the deQueue invocation leads to infinite loop.
      Now the deQueue uses while(true) and tries to receive message with 10 second time out. When queue is empty the branch containing return statement is never executed.

      Test
      Please run this test in JMSMailQueueTest:

      @Test
      void dequeueWhenQueueIsEmpty() throws Exception {
          MailQueue.MailQueueItem mailQueueItem = getMailQueue().deQueue();
      }
      

      it's never stops.

      Proposed solution to create the EmptyMailQueueException or TimeoutMailQueueException or even more specialized exception to describe the problem.
      Also in bundle with new exceptions we could add new method to the MailQueue like this

      MailQueueItem deQueue(long timeout, TimeUnit unit) throws MailQueueException, InterruptedException;
      

      to give users explicit control over timeout. This new method also gives a kind of symmetry between enQueue and deQueue.

      As an alternative I would suggest to simply return null when time is out and no message is available for return.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              ed_asatryan Edgar Asatryan
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: