pentaho/pentaho-kettle · error · KettleException

JobGetMailsFromPOP.Error.ClosingFolder

Error message

JobGetMailsFromPOP.Error.ClosingFolder

What it means

closeFolder() wraps exceptions from closing the current folder (folder.close(false/true), expunging included) into a KettleException with JobGetMailsFromPOP.Error.ClosingFolder and the folder name. Called from openFolder (reopen path) and disconnect, so it can mask an earlier problem during cleanup.

Solutions

  1. Check the chained cause — usually a_FOLDER_CLOSED/Connection dropped exception; fix network stability or increase server timeout.
  2. Avoid expunging on close if the connection is flaky (don't delete messages, or expunge explicitly earlier).
  3. Guard double-close: only call closeFolder/disconnect once per connection lifecycle.
  4. Reconnect before retrying operations if the session timed out.

Example fix

// before
closeFolder();
disconnect();
disconnect(); // second close throws
// after
closeFolder();
disconnect(); // disconnect() is idempotent internally — don't call cleanup twice
Defensive patterns

Strategy: try-catch

Validate before calling

// before close, confirm session is alive
if (!mailConnection.getStore().isConnected()) {
  log.logBasic("Store already disconnected; skipping folder close");
}

Try / catch

try {
  mailConnection.closeFolder();
} catch (KettleException e) {
  log.logBasic("Folder close failed (session likely dropped): " + e.getCause().getMessage());
}

Prevention

When it happens

Trigger: closeFolder() when the store connection dropped mid-session (network loss, server timeout), or the folder was already closed/expunged, or an expunge write fails in read-write mode.

Common situations: Long-running jobs whose IMAP session timed out before close; server forcibly disconnecting after 'delete messages' operations; calling disconnect twice.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/b7a0eec90d8456a4. Report an issue: GitHub.

Appendix: source

Thrown at plugins/email-messages/impl/src/main/java/org/pentaho/di/job/entries/getpop/MailConnection.java:604

   * @throws KettleException
   */
  public void closeFolder( boolean expunge ) throws KettleException {
    try {
      if ( this.folder != null && this.folder.isOpen() ) {
        if ( log.isDebug() ) {
          log.logDebug( BaseMessages.getString( PKG, "MailConnection.ClosingFolder", getFolderName() ) );
        }
        this.folder.close( expunge );
        this.folder = null;
        this.messages = null;
        this.message = null;
        this.messagenr = -1;
        if ( log.isDebug() ) {
          log.logDebug( BaseMessages.getString( PKG, "MailConnection.FolderClosed", getFolderName() ) );
        }
      }
    } catch ( Exception e ) {
      throw new KettleException( BaseMessages.getString(
        PKG, "JobGetMailsFromPOP.Error.ClosingFolder", getFolderName() ), e );
    }
  }

  /**
   * Add search term.
   *
   * @param term
   *          search term to add
   */
  private void addSearchTerm( SearchTerm term ) {
    if ( this.searchTerm != null ) {
      this.searchTerm = new AndTerm( this.searchTerm, term );
    } else {
      this.searchTerm = term;
    }
  }

View on GitHub (pinned to f3058517a1)