james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tellier Benoit (JIRA)" <server-...@james.apache.org>
Subject [jira] [Commented] (JAMES-2458) JMS mail queue caught in infinite loop.
Date Wed, 11 Jul 2018 05:10:00 GMT

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

Tellier Benoit commented on JAMES-2458:


I thought what you just described is the expected design of the MailQueue interface...

To quote the Java doc:

This method will block until a Mail is ready and then process the operation.

I think this choice is a bit not-intuitive, but in James use case is enough (See JamesSpooler).

I would advocate, to avoid too big changes (and responsibility shifts) to keep things as they

> JMS mail queue caught in infinite loop.
> ---------------------------------------
>                 Key: JAMES-2458
>                 URL: https://issues.apache.org/jira/browse/JAMES-2458
>             Project: James Server
>          Issue Type: Bug
>          Components: Queue
>    Affects Versions: 3.0.0, master
>            Reporter: Edgar Asatryan
>            Priority: Major
>              Labels: bug
> h2. *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*:
> {code:java}
> @Test
> void dequeueWhenQueueIsEmpty() throws Exception {
>     MailQueue.MailQueueItem mailQueueItem = getMailQueue().deQueue();
> }
> {code}
> 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
> {code:java}
> MailQueueItem deQueue(long timeout, TimeUnit unit) throws MailQueueException, InterruptedException;
> {code}
> 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.

This message was sent by Atlassian JIRA

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

View raw message