Note that there are some explanatory texts on larger screens.

plurals
  1. POJavaMail intermittently throws FolderClosedExcpetion on IMAPMessage.loadEnvelope()
    primarykey
    data
    text
    <p>I have a java service that consumes emails from a Postfix mail server. It's handling about 1 email per second and processes the content of the emails.</p> <p>However, very intermittently I get this exception:</p> <pre><code>javax.mail.FolderClosedException : * BYE [ALERT] Fatal error: Invalid argument - javax.mail.FolderClosedException: * BYE [ALERT] Fatal error: Invalid argument at com.sun.mail.imap.IMAPMessage.loadEnvelope(IMAPMessage.java:1256) at com.sun.mail.imap.IMAPMessage.getSubject(IMAPMessage.java:335) at com.mailparser.data.MessageParser.parse(MessageParser.java:33) </code></pre> <p>If I exit the process and restart it again it will always throw the same exception on the same messages and thus they get stuck in the inbox.</p> <p>here's a code snippet of where it's failing:</p> <pre><code>if (!message.getFolder().isOpen()) { message.getFolder().open(Folder.READ_WRITE); Logger.log("Tried to reopen folder"); //This is never hit } ReceivedEmail incomingMessage = new ReceivedEmail(); try { incomingMessage.setSubject(message.getSubject()); // Exception happens here [...] } catch { catch (FolderClosedException ex) { message.getFolder().open(Folder.READ_WRITE); Logger.log("Reopened", LogType.debug); return null; } } </code></pre> <p>As you can see I'm checking to see if the folder is open before I try to get the subject, so I suspect that something else is causing this failure. Once it has thrown the expections for the stuck messages it carries on successfully using exactly the same folder and connection.</p> <p>Does anyone have any idea on this?</p> <p>Thanks!</p> <p>Edit:</p> <p>Debug info as requested by Bill:</p> <pre><code> DEBUG IMAP: LOGIN command trace suppressed DEBUG IMAP: LOGIN command result: A0 OK LOGIN Ok. A1 CAPABILITY * CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE ACL ACL2=UNION A1 OK CAPABILITY completed A2 LIST INBOX "" * LIST (\Marked \HasChildren) "." "" A2 OK LIST completed A3 LIST "" INBOX.TEST * LIST (\HasChildren) "." "INBOX.TEST" A3 OK LIST completed DEBUG: connection available -- size: 1 A4 SELECT INBOX.TEST * FLAGS (\Draft \Answered \Flagged \Deleted \Seen \Recent) * OK [PERMANENTFLAGS (\* \Draft \Answered \Flagged \Deleted \Seen)] Limited * 1 EXISTS * 0 RECENT * OK [UIDVALIDITY 1351176418] Ok * OK [MYRIGHTS "acdilrsw"] ACL A4 OK [READ-WRITE] Ok DEBUG IMAP: IMAPProtocol noop A7 NOOP A7 OK NOOP completed A8 FETCH 1 (FLAGS) * 1 FETCH (FLAGS (\Answered \Seen)) A8 OK FETCH completed. A9 FETCH 1 (ENVELOPE INTERNALDATE RFC822.SIZE) * BYE [ALERT] Fatal error: Invalid argument </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload