[FIX] IMAP STATUS should better handle MailboxNotFoundException (#2158)

diff --git a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Status.test b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Status.test
index a148eaa..1ce3ffb 100644
--- a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Status.test
+++ b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Status.test
@@ -122,6 +122,9 @@
 S: \* STATUS \"statustest\" \(MESSAGES 4 SIZE 1016 DELETED 2 DELETED-STORAGE 508 UNSEEN 4\)
 S: A013 OK STATUS completed.
 
+C: A013 STATUS notfound (UNSEEN SIZE MESSAGES DELETED DELETED-STORAGE)
+S: A013 NO STATUS failed. Mailbox not found.
+
 C: A014 STATUS statustest (DELETED)
 S: \* STATUS \"statustest\" \(DELETED 2\)
 S: A014 OK STATUS completed.
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/StatusProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/StatusProcessor.java
index a9f242e..59314fc 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/StatusProcessor.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/StatusProcessor.java
@@ -45,6 +45,7 @@
 import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.ModSeq;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.exception.MailboxNotFoundException;
 import org.apache.james.mailbox.model.ComposedMessageIdWithMetaData;
 import org.apache.james.mailbox.model.FetchGroup;
 import org.apache.james.mailbox.model.MailboxId;
@@ -103,6 +104,10 @@
             .then(sendStatus(mailboxPath, statusDataItems, responder, session, mailboxSession))
             .then(unsolicitedResponses(session, responder, false))
             .then(Mono.fromRunnable(() -> okComplete(request, responder)))
+            .onErrorResume(MailboxNotFoundException.class, e -> {
+                no(request, responder, HumanReadableText.MAILBOX_NOT_FOUND);
+                return ReactorUtils.logAsMono(() -> LOGGER.info("Status failed for mailbox '{}' as it does not exist.", mailboxPath));
+            })
             .onErrorResume(MailboxException.class, e -> {
                 no(request, responder, HumanReadableText.STATUS_FAILED);
                 return ReactorUtils.logAsMono(() -> LOGGER.error("Status failed for mailbox {}", mailboxPath, e));