pentaho/pentaho-kettle · warning · KettleException

JobGetMailsFromPOP.Error.ClosingConnection

Error message

JobGetMailsFromPOP.Error.ClosingConnection

What it means

disconnect() wraps exceptions raised while closing the folder and store (its internal cleanup steps) into a KettleException with JobGetMailsFromPOP.Error.ClosingConnection. It means the session could not be shut down cleanly — usually because the server already dropped the connection.

Solutions

  1. Inspect the chained cause — typically a socket/ConnectionException meaning the server already closed; safe to treat as cleanup warning.
  2. Ensure disconnect() is called in a finally block exactly once after the job step completes.
  3. Enable IMAP keepalive or shorten job duration to stay under the server idle timeout.
  4. If it recurs, log-and-continue on disconnect failures since resources are usually released server-side anyway.

Example fix

// before
disconnect(); // throws if server already dropped
// after
try {
  disconnect();
} catch (KettleException e) {
  log.logBasic("Connection already closed by server: " + e.getMessage());
}
Defensive patterns

Strategy: try-catch

Validate before calling

// only disconnect once, after confirming state
if (mailConnection != null && mailConnection.getStore() != null && mailConnection.getStore().isConnected()) {
  mailConnection.disconnect();
}

Try / catch

try {
  mailConnection.disconnect();
} catch (KettleException e) {
  log.logBasic("Disconnect failed, server likely already closed: " + e.getCause().getMessage());
}

Prevention

When it happens

Trigger: disconnect() calls closeFolder()/store.close() and any of them throws: socket already closed, session timed out, SSL channel broken.

Common situations: Server-side idle timeouts (e.g. 30 min IMAP logout), network drop between connect and disconnect, exception in job flow skipping normal close then disconnect failing again.

Related errors


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

Appendix: source

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

      // close the folder, passing in a true value to expunge the deleted message
      closeFolder( expunge );
      clearFilters();
      if ( this.store != null ) {
        this.store.close();
        this.store = null;
      }
      if ( this.session != null ) {
        this.session = null;
      }
      if ( this.destinationIMAPFolder != null ) {
        this.destinationIMAPFolder.close( expunge );
      }

      if ( log.isDebug() ) {
        log.logDebug( BaseMessages.getString( PKG, "MailConnection.ConnectionClosed" ) );
      }
    } catch ( Exception e ) {
      throw new KettleException( BaseMessages.getString( PKG, "JobGetMailsFromPOP.Error.ClosingConnection" ), e );
    }
  }

  /**
   * Export message content to a filename.
   *
   * @param filename
   *          the target filename
   * @param foldername
   *          the parent folder of filename
   * @throws KettleException
   */

  public void saveMessageContentToFile( String filename, String foldername ) throws KettleException {
    OutputStream os = null;
    try {
      os = KettleVFS.getInstance( bowl )
        .getOutputStream( foldername + ( foldername.endsWith( "/" ) ? "" : "/" ) + filename, false );

View on GitHub (pinned to f3058517a1)