openbas
openbas copied to clipboard
Missing close statement for IMAP folder triggering a connect issue after a few minutes on some IMAP server
Description
IMAP connection may start to trigger error after 1 minute
Environment
- OS Windows 10
- OpenEx version: OpenEx 3.2.2 (latest)
- OpenEx client: None
- Other environment details: O365 IMAP server
Reproducible Steps
Steps to create the smallest reproducible scenario:
- Start the application
- Wait 1 minute
- The error BAD user is authenticated but not connected
Expected Output
No error message
Actual Output
An exception appears with a stack trace starting at: https://github.com/OpenEx-Platform/openex/blob/0239961bfdc3cd13e11b4efc7f780b75ba151ca5/openex-api/src/main/java/io/openex/injects/email/service/ImapService.java#L280
Additional information
In this function, the IMAP folder is opened, but never closed. This error happens twice here and here Adding a close statement just below fixes the issue.
private void syncFolders() throws Exception {
// Sync sent
Folder sentBox = imapStore.getFolder(sentFolder);
sentBox.open(Folder.READ_ONLY);
synchronizeBox(sentBox, true);
sentBox.close();
// Sync received
for (String listeningFolder : inboxFolders) {
Folder inbox = imapStore.getFolder(listeningFolder);
inbox.open(Folder.READ_ONLY);
synchronizeBox(inbox, false);
inbox.close();
}
}
Screenshots (optional)
see PR #289