Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
minLevel1
maxLevel7

Overview

A FolderClosedException (FCE) is caused when the connection between Jira and the inbound Mail server is closed abruptly by the mail server whilst mail is being retrieved. JEMH is not responsible for the mail connection, which is handled by Jira.

Symptoms

...

Why does it happen

Your mailserver can drop connections for two main reasons:

Too many concurrent logins using the same account

Your mailserver may simply kill off the one that is oldest, which was unfortunately still in use. To check if this is a problem, count how many inbound mail servers you have defined using the same account. If its more than 15 you could be affected.

Mails are taking too long to download

The mailserver may determine the connection ‘dead’ if it takes too long to complete, caused by large emails taking too long.

JEMH

To verify if this problem affects you, and action you can take to increase the default batching size as described in Download performance of POP vs IMAP.

(info) If you have just upgraded your Jira, check that you have migrated the customization to the environment (eg setenv.sh)

JEMHC

JEMHC automatically sets the properties to avoid batch size related problems.

When I see FolderClosed, is that a bug?

No, this is not a bug, it's just the consequence of your mail-server closing the connection to JEMH/C whilst the mail was still being read (by JEMH). It is not caused by JEMH/C and cannot be solved by JEMH/C. See Impact and Migration steps possible:

When a FolderClosedException occurs, it stops all mail processing, specifically, as the mail was not read fully:

  • it was not processed at all, will not be consumed / marked read and will be retried

  • it will not be available in JEMH Auditing and cannot be exported as part of the support zip

JEMH Specific diagnostics

What you see in JEMH Auditing

Current versions of JEMH prevent the ‘download’ button operating and show the following information dialog:

...

The popup links to Download performance of POP vs IMAP and an Atlassian article:
https://confluence.atlassian.com/jirakb/imap-mail-fails-with-folderclosedexception-in-logs-in-jira-server-385319403.html .

JEMH Logs

Below is a stack trace error for the FolderClosedException that shows up in the 'atlassian-jira-incoming-mail.log', jemh.log and the JEMH processing Report.

Code Block
2013-07-12 09:52:50,478 ERROR [xxx] QuartzScheduler_Worker-3 ServiceRunner xxxx[xxxxx]: Exception: null
javax.mail.FolderClosedException
	at com.sun.mail.imap.IMAPMessage.getProtocol(IMAPMessage.java:145)
	at com.sun.mail.imap.IMAPMessage.getHeader(IMAPMessage.java:743)
	at com.atlassian.jira.service.services.mail.MailFetcherService$MessageProviderImpl.getAndProcessMail(MailFetcherService.java:257)
	at com.atlassian.jira.service.services.mail.MailFetcherService.runImpl(MailFetcherService.java:356)
	at com.atlassian.jira.service.services.file.AbstractMessageHandlingService.run(AbstractMessageHandlingService.java:257)
	at com.atlassian.jira.service.JiraServiceContainerImpl.run(JiraServiceContainerImpl.java:61)
	at com.atlassian.jira.service.ServiceRunner.execute(ServiceRunner.java:48)
	at org.quartz.core.JobRunShell.run(JobRunShell.java:195)

If enabled, JEMH Inbound Auditing will also add this exception to the Inbound processing report, and attempting to download the related email, or generate a Support ZIP the following popup will be shown:

...

Causes

Large Emails

Mail items that are too large and take an excessive time to be retrieved can result in a FolderClosedException, as the mail server interoperates the long retreival time as an error, and closes the connection. This can be compounded if using the IMAP protocol which has a low default ‘Fetch’ size which makes mail retrial of larger mail items significantly slower. See for more info and steps to increase IMAP ‘Fetch’ size:

Concurrent logins

Mail servers have limits on the number of active connections for mail retrieval. If this limit is exceeded the mail server will close existing mail connections to create new connections. If mail is being retrieved and the connection is closed a FolderClosedException is created. Jira and JEMH work best when using a Mail server with limited mail connections, dedicated to automation.

If using multiple JEMH profiles to access the same mailbox, consider using a profile group to group multiple mail handlers to a single mail connection, to reduce traffic and boost performance:

...