Author: norman
Date: Sat Apr 16 16:55:29 2011
New Revision: 1094016

URL: http://svn.apache.org/viewvc?rev=1094016&view=rev
Log:
Throw MessageRangeException if Mailbox is empty an a msn is requested

Modified:
    
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractMailboxProcessor.java

Modified: 
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractMailboxProcessor.java
URL: 
http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractMailboxProcessor.java?rev=1094016&r1=1094015&r2=1094016&view=diff
==============================================================================
--- 
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractMailboxProcessor.java
 (original)
+++ 
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractMailboxProcessor.java
 Sat Apr 16 16:55:29 2011
@@ -362,7 +362,11 @@ abstract public class AbstractMailboxPro
             // Take care of "*" and "*:*" values by return the last message in
             // the mailbox. See IMAP-289
             if (lowVal == Long.MAX_VALUE && highVal == Long.MAX_VALUE) {
-                return MessageRange.one(selected.getLastUid());
+                highVal = selected.getLastUid();
+                if (highVal == SelectedMailbox.NO_SUCH_MESSAGE) {
+                    throw new MessageRangeException("Mailbox is empty");
+                }
+                return MessageRange.one(highVal);
             }
 
             if (lowVal != Long.MIN_VALUE) {
@@ -371,6 +375,9 @@ abstract public class AbstractMailboxPro
                     throw new MessageRangeException("No message found with msn 
" + lowVal);
             } else {
                 lowVal = selected.getFirstUid();
+                if (lowVal == SelectedMailbox.NO_SUCH_MESSAGE) {
+                    throw new MessageRangeException("Mailbox is empty");
+                }
             }
             if (highVal != Long.MAX_VALUE) {
                 highVal = selected.uid((int) highVal);
@@ -378,6 +385,9 @@ abstract public class AbstractMailboxPro
                     throw new MessageRangeException("No message found with msn 
" + highVal);
             } else {
                 highVal = selected.getLastUid();
+                if (highVal == SelectedMailbox.NO_SUCH_MESSAGE) {
+                    throw new MessageRangeException("Mailbox is empty");
+                }
             }
             
         } else {



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to