bbottema / simple-java-mail

Simple API, Complex Emails (Jakarta Mail smtp wrapper)

Home Page:http://www.simplejavamail.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sending async emails with and without the Batch module causes lingering threads (preventing the JVM from shutting down)

bbottema opened this issue · comments

There are a couple of issues all of the same type:

  1. The aggregate future task that waits for all connection pools to shut down is itself not being executed
  2. The loop inside the aggregate future task is broken and loops forever so even if it is executed, it doesn't finish
  3. There are a few instances where a default executor service instance is created and used but never shut down internally.

These all block the JVM from shutting down. The connection pools and threads properly die, the management around these threads don't.

Part of issue 3 is that when mailer.shutdownConnectionPool() is invoked, the executor service is not shutdown. This is part of the bug, but it should only do so when the executor service was not manually provided by the user.

All the issues are fixed, but I can't release because OSS Sonatype isn't syncing properly to Maven Central currently. The smtp-connection-pool library isn't showing up...

Just did a quick test with org.simplejavamail:smtp-connection-pool:1.1.0. Looks good! No more blocking.

Fixed in 6.0.2