openbas icon indicating copy to clipboard operation
openbas copied to clipboard

Missing close statement for IMAP folder triggering a connect issue after a few minutes on some IMAP server

Open vletoux opened this issue 9 months ago • 1 comments

Description

IMAP connection may start to trigger error after 1 minute

Environment

  1. OS Windows 10
  2. OpenEx version: OpenEx 3.2.2 (latest)
  3. OpenEx client: None
  4. Other environment details: O365 IMAP server

Reproducible Steps

Steps to create the smallest reproducible scenario:

  1. Start the application
  2. Wait 1 minute
  3. 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)

vletoux avatar Sep 19 '23 13:09 vletoux

see PR #289

vletoux avatar Sep 19 '23 13:09 vletoux