Skip to content

[bug] Mailer.close() exception because it attempts to shutdown batch-module connection pools, even if not available on the classpath #558

Closed

Description

@rzam

It seems that attempting to close a non-async Mailer (either explicitly via .close() or implicitly via try-with) will cause it to throw a ModuleLoaderException.

Minimal working example:

// Gradle
dependencies {
    implementation("org.simplejavamail:simple-java-mail:8.12.2")
}
try (Mailer mailer = MailerBuilder
        .withSMTPServer("localhost", 25, null, null)
        .buildMailer()) {
    // Do nothing
}

Result:

Exception in thread "main" org.simplejavamail.internal.moduleloader.ModuleLoaderException: Batch module not found, make sure it is on the classpath (https://github.com/bbottema/simple-java-mail/tree/develop/modules/batch-module)
	at org.simplejavamail.internal.moduleloader.ModuleLoader.loadModule(ModuleLoader.java:133)
	at org.simplejavamail.internal.moduleloader.ModuleLoader.loadBatchModule(ModuleLoader.java:95)
	at org.simplejavamail.mailer.internal.MailerImpl.shutdownConnectionPool(MailerImpl.java:395)
	at org.simplejavamail.mailer.internal.MailerImpl.close(MailerImpl.java:474)
	at Test.main(Test.java:11)

Activity

  1. bbottema commented on Oct 17, 2024

    @bbottema
    Owner

    I thought I was had addressed this recently. I'll have a look.

  2. added a commit that references this issue on Dec 12, 2024
  3. added this to the 8.12.4 milestone on Dec 12, 2024
  4. changed the title [-]`Mailer::close` attempts to access the batch module regardless of configuration[/-] [+][bug] Mailer.close() exception because it attempts to shutdown batch-module connection pools, even if not available on the classpath[/+] on Dec 12, 2024
  5. bbottema commented on Dec 12, 2024

    @bbottema
    Owner

    Fix released in 8.12.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions